This commit is contained in:
@@ -97,7 +97,7 @@ namespace AyaNova.Api.Controllers
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
if (!ModelState.IsValid)
|
||||
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));
|
||||
return Ok(ApiOkResponse.Response(o));
|
||||
}
|
||||
@@ -125,7 +125,7 @@ namespace AyaNova.Api.Controllers
|
||||
else
|
||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
}
|
||||
return Ok(ApiOkResponse.Response(new { Concurrency = o.Concurrency }));;
|
||||
return Ok(ApiOkResponse.Response(new { Concurrency = o.Concurrency })); ;
|
||||
}
|
||||
|
||||
/// <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["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 ##############################
|
||||
|
||||
@@ -8,7 +8,6 @@ using System;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace AyaNova.Biz
|
||||
{
|
||||
@@ -90,13 +89,14 @@ namespace AyaNova.Biz
|
||||
await SearchIndexAsync(newObject, true);
|
||||
await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null);
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Created, newObject);
|
||||
await PopulateVizFields(newObject);
|
||||
return newObject;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//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
|
||||
.Include(z => z.ContractPartOverrideItems)
|
||||
@@ -106,6 +106,10 @@ namespace AyaNova.Biz
|
||||
.Include(z => z.TravelRateItems)
|
||||
.AsNoTracking()
|
||||
.SingleOrDefaultAsync(m => m.Id == id);
|
||||
|
||||
if (populateDisplayFields)
|
||||
await PopulateVizFields(ret);
|
||||
|
||||
if (logTheGetEvent && ret != null)
|
||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, id, BizType, AyaEvent.Retrieved), ct);
|
||||
return ret;
|
||||
@@ -150,6 +154,7 @@ namespace AyaNova.Biz
|
||||
await SearchIndexAsync(putObject, false);
|
||||
await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, putObject.Tags, dbObject.Tags);
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject);
|
||||
await PopulateVizFields(putObject);
|
||||
return putObject;
|
||||
}
|
||||
|
||||
@@ -437,9 +442,12 @@ namespace AyaNova.Biz
|
||||
var batchResults = await ct.Contract.AsNoTracking().Where(z => batch.Contains(z.Id)).ToArrayAsync();
|
||||
//order the results back into original
|
||||
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)
|
||||
{
|
||||
await PopulateVizFields(w);
|
||||
await PopulateVizFields(w, ContractOverrideTypeEnumList);
|
||||
var jo = JObject.FromObject(w);
|
||||
if (!JsonUtil.JTokenIsNullOrEmpty(jo["CustomFields"]))
|
||||
jo["CustomFields"] = JObject.Parse((string)jo["CustomFields"]);
|
||||
@@ -450,12 +458,24 @@ namespace AyaNova.Biz
|
||||
}
|
||||
|
||||
//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)
|
||||
// o.HeadOfficeViz = await ct.HeadOffice.AsNoTracking().Where(x=>x.Id==o.HeadOfficeId).Select(x => x.Name).FirstOrDefaultAsync();
|
||||
// if (o.ContractId != null)
|
||||
// o.ContractViz = await ct.Contract.AsNoTracking().Where(x=>x.Id==o.ContractId).Select(x => x.Name).FirstOrDefaultAsync();
|
||||
if (contractOverrideTypeEnumList == null)
|
||||
contractOverrideTypeEnumList = await AyaNova.Api.Controllers.EnumListController.GetEnumList(StringUtil.TrimTypeName(typeof(ContractOverrideType).ToString()), UserTranslationId);
|
||||
|
||||
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; }
|
||||
[Required]
|
||||
public ContractOverrideType PartsOverrideType { get; set; }
|
||||
[NotMapped]
|
||||
public string PartsOverrideTypeViz { get; set; }
|
||||
[Required]
|
||||
public decimal ServiceRatesOverridePct { get; set; }
|
||||
[Required]
|
||||
public ContractOverrideType ServiceRatesOverrideType { get; set; }
|
||||
[NotMapped]
|
||||
public string ServiceRatesOverrideTypeViz { get; set; }
|
||||
[Required]
|
||||
public decimal TravelRatesOverridePct { get; set; }
|
||||
[Required]
|
||||
public ContractOverrideType TravelRatesOverrideType { get; set; }
|
||||
[NotMapped]
|
||||
public string TravelRatesOverrideTypeViz { get; set; }
|
||||
public string AlertNotes { get; set; }//alert on workorder etc
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using AyaNova.Biz;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
@@ -16,6 +17,8 @@ namespace AyaNova.Models
|
||||
public decimal OverridePct { get; set; }
|
||||
[Required]
|
||||
public ContractOverrideType OverrideType { get; set; }
|
||||
[NotMapped]
|
||||
public string OverrideTypeViz { get; set; }
|
||||
[Required]
|
||||
public List<string> Tags { get; set; }
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
namespace AyaNova.Models
|
||||
{
|
||||
public class ContractServiceRate
|
||||
@@ -9,9 +11,11 @@ namespace AyaNova.Models
|
||||
public uint Concurrency { get; set; }
|
||||
|
||||
[Required]
|
||||
public long ContractId { get; set; }
|
||||
public long ContractId { get; set; }
|
||||
[Required]
|
||||
public long ServiceRateId { get; set; }
|
||||
[NotMapped]
|
||||
public string ServiceRateViz { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public Contract Contract { get; set; }
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using AyaNova.Biz;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
@@ -16,6 +17,8 @@ namespace AyaNova.Models
|
||||
public decimal OverridePct { get; set; }
|
||||
[Required]
|
||||
public ContractOverrideType OverrideType { get; set; }
|
||||
[NotMapped]
|
||||
public string OverrideTypeViz { get; set; }
|
||||
[Required]
|
||||
public List<string> Tags { get; set; }
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace AyaNova.Models
|
||||
@@ -12,6 +13,8 @@ namespace AyaNova.Models
|
||||
public long ContractId { get; set; }
|
||||
[Required]
|
||||
public long TravelRateId { get; set; }
|
||||
[NotMapped]
|
||||
public string TravelRateViz { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public Contract Contract { get; set; }
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using AyaNova.Biz;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
@@ -16,6 +17,8 @@ namespace AyaNova.Models
|
||||
public decimal OverridePct { get; set; }
|
||||
[Required]
|
||||
public ContractOverrideType OverrideType { get; set; }
|
||||
[NotMapped]
|
||||
public string OverrideTypeViz { get; set; }
|
||||
[Required]
|
||||
public List<string> Tags { get; set; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user