This commit is contained in:
@@ -97,7 +97,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
return BadRequest(new ApiErrorResponse(ModelState));
|
return BadRequest(new ApiErrorResponse(ModelState));
|
||||||
var o = await biz.GetAsync(id);
|
var o = await biz.GetAsync(id, true);
|
||||||
if (o == null) return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
if (o == null) return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
||||||
return Ok(ApiOkResponse.Response(o));
|
return Ok(ApiOkResponse.Response(o));
|
||||||
}
|
}
|
||||||
@@ -125,7 +125,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
else
|
else
|
||||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||||
}
|
}
|
||||||
return Ok(ApiOkResponse.Response(new { Concurrency = o.Concurrency }));;
|
return Ok(ApiOkResponse.Response(new { Concurrency = o.Concurrency })); ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -459,6 +459,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
|
|
||||||
ReturnList.Add(new NameIdItem() { Name = LT["ContractOverrideTypePriceDiscount"], Id = (long)ContractOverrideType.PriceDiscount });
|
ReturnList.Add(new NameIdItem() { Name = LT["ContractOverrideTypePriceDiscount"], Id = (long)ContractOverrideType.PriceDiscount });
|
||||||
ReturnList.Add(new NameIdItem() { Name = LT["ContractOverrideTypeMarkup"], Id = (long)ContractOverrideType.CostMarkup });
|
ReturnList.Add(new NameIdItem() { Name = LT["ContractOverrideTypeMarkup"], Id = (long)ContractOverrideType.CostMarkup });
|
||||||
|
ReturnList.Add(new NameIdItem() { Name = "-", Id = (long)ContractOverrideType.NotSet });
|
||||||
}
|
}
|
||||||
//#################################################################################################################
|
//#################################################################################################################
|
||||||
//################### NEW HERE DO NOT FORGET TO ADD TO LISTS AVAILABLE ABOVE AS WELL ##############################
|
//################### NEW HERE DO NOT FORGET TO ADD TO LISTS AVAILABLE ABOVE AS WELL ##############################
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ using System;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
namespace AyaNova.Biz
|
namespace AyaNova.Biz
|
||||||
{
|
{
|
||||||
@@ -90,13 +89,14 @@ namespace AyaNova.Biz
|
|||||||
await SearchIndexAsync(newObject, true);
|
await SearchIndexAsync(newObject, true);
|
||||||
await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null);
|
await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null);
|
||||||
await HandlePotentialNotificationEvent(AyaEvent.Created, newObject);
|
await HandlePotentialNotificationEvent(AyaEvent.Created, newObject);
|
||||||
|
await PopulateVizFields(newObject);
|
||||||
return newObject;
|
return newObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//GET
|
//GET
|
||||||
//
|
//
|
||||||
internal async Task<Contract> GetAsync(long id, bool logTheGetEvent = true)
|
internal async Task<Contract> GetAsync(long id, bool populateDisplayFields, bool logTheGetEvent = true)
|
||||||
{
|
{
|
||||||
var ret = await ct.Contract
|
var ret = await ct.Contract
|
||||||
.Include(z => z.ContractPartOverrideItems)
|
.Include(z => z.ContractPartOverrideItems)
|
||||||
@@ -106,6 +106,10 @@ namespace AyaNova.Biz
|
|||||||
.Include(z => z.TravelRateItems)
|
.Include(z => z.TravelRateItems)
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
.SingleOrDefaultAsync(m => m.Id == id);
|
.SingleOrDefaultAsync(m => m.Id == id);
|
||||||
|
|
||||||
|
if (populateDisplayFields)
|
||||||
|
await PopulateVizFields(ret);
|
||||||
|
|
||||||
if (logTheGetEvent && ret != null)
|
if (logTheGetEvent && ret != null)
|
||||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, id, BizType, AyaEvent.Retrieved), ct);
|
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, id, BizType, AyaEvent.Retrieved), ct);
|
||||||
return ret;
|
return ret;
|
||||||
@@ -150,6 +154,7 @@ namespace AyaNova.Biz
|
|||||||
await SearchIndexAsync(putObject, false);
|
await SearchIndexAsync(putObject, false);
|
||||||
await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, putObject.Tags, dbObject.Tags);
|
await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, putObject.Tags, dbObject.Tags);
|
||||||
await HandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject);
|
await HandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject);
|
||||||
|
await PopulateVizFields(putObject);
|
||||||
return putObject;
|
return putObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -437,9 +442,12 @@ namespace AyaNova.Biz
|
|||||||
var batchResults = await ct.Contract.AsNoTracking().Where(z => batch.Contains(z.Id)).ToArrayAsync();
|
var batchResults = await ct.Contract.AsNoTracking().Where(z => batch.Contains(z.Id)).ToArrayAsync();
|
||||||
//order the results back into original
|
//order the results back into original
|
||||||
var orderedList = from id in batch join z in batchResults on id equals z.Id select z;
|
var orderedList = from id in batch join z in batchResults on id equals z.Id select z;
|
||||||
|
|
||||||
|
//cache enum list
|
||||||
|
var ContractOverrideTypeEnumList = await AyaNova.Api.Controllers.EnumListController.GetEnumList(StringUtil.TrimTypeName(typeof(ContractOverrideType).ToString()), UserTranslationId);
|
||||||
foreach (Contract w in orderedList)
|
foreach (Contract w in orderedList)
|
||||||
{
|
{
|
||||||
await PopulateVizFields(w);
|
await PopulateVizFields(w, ContractOverrideTypeEnumList);
|
||||||
var jo = JObject.FromObject(w);
|
var jo = JObject.FromObject(w);
|
||||||
if (!JsonUtil.JTokenIsNullOrEmpty(jo["CustomFields"]))
|
if (!JsonUtil.JTokenIsNullOrEmpty(jo["CustomFields"]))
|
||||||
jo["CustomFields"] = JObject.Parse((string)jo["CustomFields"]);
|
jo["CustomFields"] = JObject.Parse((string)jo["CustomFields"]);
|
||||||
@@ -450,12 +458,24 @@ namespace AyaNova.Biz
|
|||||||
}
|
}
|
||||||
|
|
||||||
//populate viz fields from provided object
|
//populate viz fields from provided object
|
||||||
private async Task PopulateVizFields(Contract o)
|
private async Task PopulateVizFields(Contract o, List<NameIdItem> contractOverrideTypeEnumList = null)
|
||||||
{
|
{
|
||||||
// if (o.HeadOfficeId != null)
|
if (contractOverrideTypeEnumList == null)
|
||||||
// o.HeadOfficeViz = await ct.HeadOffice.AsNoTracking().Where(x=>x.Id==o.HeadOfficeId).Select(x => x.Name).FirstOrDefaultAsync();
|
contractOverrideTypeEnumList = await AyaNova.Api.Controllers.EnumListController.GetEnumList(StringUtil.TrimTypeName(typeof(ContractOverrideType).ToString()), UserTranslationId);
|
||||||
// if (o.ContractId != null)
|
|
||||||
// o.ContractViz = await ct.Contract.AsNoTracking().Where(x=>x.Id==o.ContractId).Select(x => x.Name).FirstOrDefaultAsync();
|
o.PartsOverrideTypeViz = contractOverrideTypeEnumList.Where(x => x.Id == (long)o.PartsOverrideType).Select(x => x.Name).First();
|
||||||
|
o.TravelRatesOverrideTypeViz = contractOverrideTypeEnumList.Where(x => x.Id == (long)o.TravelRatesOverrideType).Select(x => x.Name).First();
|
||||||
|
o.ServiceRatesOverrideTypeViz = contractOverrideTypeEnumList.Where(x => x.Id == (long)o.ServiceRatesOverrideType).Select(x => x.Name).First();
|
||||||
|
foreach (var i in o.ContractPartOverrideItems)
|
||||||
|
i.OverrideTypeViz = contractOverrideTypeEnumList.Where(x => x.Id == (long)i.OverrideType).Select(x => x.Name).First();
|
||||||
|
foreach (var i in o.ContractTravelRateOverrideItems)
|
||||||
|
i.OverrideTypeViz = contractOverrideTypeEnumList.Where(x => x.Id == (long)i.OverrideType).Select(x => x.Name).First();
|
||||||
|
foreach (var i in o.ContractServiceRateOverrideItems)
|
||||||
|
i.OverrideTypeViz = contractOverrideTypeEnumList.Where(x => x.Id == (long)i.OverrideType).Select(x => x.Name).First();
|
||||||
|
foreach (var i in o.ServiceRateItems)
|
||||||
|
i.ServiceRateViz = await ct.ServiceRate.AsNoTracking().Where(x => x.Id == i.ServiceRateId).Select(x => x.Name).FirstOrDefaultAsync();
|
||||||
|
foreach (var i in o.TravelRateItems)
|
||||||
|
i.TravelRateViz = await ct.TravelRate.AsNoTracking().Where(x => x.Id == i.TravelRateId).Select(x => x.Name).FirstOrDefaultAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -33,14 +33,20 @@ namespace AyaNova.Models
|
|||||||
public decimal PartsOverridePct { get; set; }
|
public decimal PartsOverridePct { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public ContractOverrideType PartsOverrideType { get; set; }
|
public ContractOverrideType PartsOverrideType { get; set; }
|
||||||
|
[NotMapped]
|
||||||
|
public string PartsOverrideTypeViz { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public decimal ServiceRatesOverridePct { get; set; }
|
public decimal ServiceRatesOverridePct { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public ContractOverrideType ServiceRatesOverrideType { get; set; }
|
public ContractOverrideType ServiceRatesOverrideType { get; set; }
|
||||||
|
[NotMapped]
|
||||||
|
public string ServiceRatesOverrideTypeViz { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public decimal TravelRatesOverridePct { get; set; }
|
public decimal TravelRatesOverridePct { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public ContractOverrideType TravelRatesOverrideType { get; set; }
|
public ContractOverrideType TravelRatesOverrideType { get; set; }
|
||||||
|
[NotMapped]
|
||||||
|
public string TravelRatesOverrideTypeViz { get; set; }
|
||||||
public string AlertNotes { get; set; }//alert on workorder etc
|
public string AlertNotes { get; set; }//alert on workorder etc
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using AyaNova.Biz;
|
using AyaNova.Biz;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
@@ -16,6 +17,8 @@ namespace AyaNova.Models
|
|||||||
public decimal OverridePct { get; set; }
|
public decimal OverridePct { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public ContractOverrideType OverrideType { get; set; }
|
public ContractOverrideType OverrideType { get; set; }
|
||||||
|
[NotMapped]
|
||||||
|
public string OverrideTypeViz { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public List<string> Tags { get; set; }
|
public List<string> Tags { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
|
||||||
namespace AyaNova.Models
|
namespace AyaNova.Models
|
||||||
{
|
{
|
||||||
public class ContractServiceRate
|
public class ContractServiceRate
|
||||||
@@ -12,6 +14,8 @@ namespace AyaNova.Models
|
|||||||
public long ContractId { get; set; }
|
public long ContractId { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public long ServiceRateId { get; set; }
|
public long ServiceRateId { get; set; }
|
||||||
|
[NotMapped]
|
||||||
|
public string ServiceRateViz { get; set; }
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public Contract Contract { get; set; }
|
public Contract Contract { get; set; }
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using AyaNova.Biz;
|
using AyaNova.Biz;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
@@ -16,6 +17,8 @@ namespace AyaNova.Models
|
|||||||
public decimal OverridePct { get; set; }
|
public decimal OverridePct { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public ContractOverrideType OverrideType { get; set; }
|
public ContractOverrideType OverrideType { get; set; }
|
||||||
|
[NotMapped]
|
||||||
|
public string OverrideTypeViz { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public List<string> Tags { get; set; }
|
public List<string> Tags { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace AyaNova.Models
|
namespace AyaNova.Models
|
||||||
@@ -12,6 +13,8 @@ namespace AyaNova.Models
|
|||||||
public long ContractId { get; set; }
|
public long ContractId { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public long TravelRateId { get; set; }
|
public long TravelRateId { get; set; }
|
||||||
|
[NotMapped]
|
||||||
|
public string TravelRateViz { get; set; }
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public Contract Contract { get; set; }
|
public Contract Contract { get; set; }
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using AyaNova.Biz;
|
using AyaNova.Biz;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
@@ -16,6 +17,8 @@ namespace AyaNova.Models
|
|||||||
public decimal OverridePct { get; set; }
|
public decimal OverridePct { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public ContractOverrideType OverrideType { get; set; }
|
public ContractOverrideType OverrideType { get; set; }
|
||||||
|
[NotMapped]
|
||||||
|
public string OverrideTypeViz { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public List<string> Tags { get; set; }
|
public List<string> Tags { get; set; }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user