This commit is contained in:
@@ -84,6 +84,32 @@ namespace AyaNova.Api.Controllers
|
|||||||
return Ok(ApiOkResponse.Response(o));
|
return Ok(ApiOkResponse.Response(o));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get a single item's name display in PickList templated format
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pickListSingleParams"></param>
|
||||||
|
/// <returns>One display string or an empty string if not found or invalid</returns>
|
||||||
|
[HttpPost("single")]
|
||||||
|
public async Task<IActionResult> PostSingle([FromBody] PickListSingleOptions pickListSingleParams)
|
||||||
|
{
|
||||||
|
if (serverState.IsClosed)
|
||||||
|
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||||
|
|
||||||
|
if (!ModelState.IsValid)
|
||||||
|
return BadRequest(new ApiErrorResponse(ModelState));
|
||||||
|
|
||||||
|
if (!Authorized.HasSelectRole(HttpContext.Items, pickListSingleParams.AyaType))
|
||||||
|
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||||
|
|
||||||
|
//Instantiate the business object handler
|
||||||
|
PickListBiz biz = PickListBiz.GetBiz(ct, HttpContext);
|
||||||
|
|
||||||
|
var o = await biz.GetTemplatedNameAsync(pickListSingleParams.AyaType, pickListSingleParams.Id, pickListSingleParams.ListVariant, log);
|
||||||
|
if (o == null)
|
||||||
|
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||||
|
else
|
||||||
|
return Ok(ApiOkResponse.Response(o));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -42,4 +42,24 @@ namespace AyaNova.PickList
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public sealed class PickListSingleOptions
|
||||||
|
{
|
||||||
|
|
||||||
|
[FromBody]
|
||||||
|
public AyaType AyaType { get; set; }
|
||||||
|
|
||||||
|
[FromBody]
|
||||||
|
public long Id { get; set; }
|
||||||
|
|
||||||
|
[FromBody]
|
||||||
|
public string ListVariant { get; set; }
|
||||||
|
|
||||||
|
public PickListSingleOptions()
|
||||||
|
{
|
||||||
|
AyaType = AyaType.NoType;
|
||||||
|
Id = 0;
|
||||||
|
ListVariant = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -134,11 +134,27 @@ namespace AyaNova.Biz
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Autocomplete and tagonly query terms now set for consumption by PickListFetcher, ready to fetch...
|
//Autocomplete and tagonly query terms now set for consumption by PickListFetcher, ready to fetch...
|
||||||
List<NameIdActiveItem> items = await PickListFetcher.GetResponseAsync(PickList, AutoCompleteQuery, TagSpecificQuery, inactive, preIds,variant, ct, log);
|
List<NameIdActiveItem> items = await PickListFetcher.GetResponseAsync(PickList, AutoCompleteQuery, TagSpecificQuery, inactive, preIds, variant, ct, log);
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//get picklist display for a single item
|
||||||
|
//used to populate UI with picklist format display for items
|
||||||
|
internal async Task<string> GetTemplatedNameAsync(AyaType ayaType, long id, string variant, ILogger log)
|
||||||
|
{
|
||||||
|
long[] preIds = { id };
|
||||||
|
var PickList = PickListFactory.GetAyaPickList(ayaType);
|
||||||
|
//Autocomplete and tagonly query terms now set for consumption by PickListFetcher, ready to fetch...
|
||||||
|
List<NameIdActiveItem> items = await PickListFetcher.GetResponseAsync(PickList, null, null, true, preIds, variant, ct, log);
|
||||||
|
if (items.Count == 0)
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
return items[0].Name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//get picklist templates, basically all the object types that support picklists
|
//get picklist templates, basically all the object types that support picklists
|
||||||
internal List<NameIdItem> GetListOfAllPickListTypes(long translationId)
|
internal List<NameIdItem> GetListOfAllPickListTypes(long translationId)
|
||||||
{
|
{
|
||||||
@@ -146,8 +162,6 @@ namespace AyaNova.Biz
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//UPDATE
|
//UPDATE
|
||||||
//
|
//
|
||||||
@@ -171,7 +185,7 @@ namespace AyaNova.Biz
|
|||||||
return false;
|
return false;
|
||||||
if (bAdd)
|
if (bAdd)
|
||||||
await ct.PickListTemplate.AddAsync(o);
|
await ct.PickListTemplate.AddAsync(o);
|
||||||
|
|
||||||
await ct.SaveChangesAsync();
|
await ct.SaveChangesAsync();
|
||||||
|
|
||||||
//Log modification and save context
|
//Log modification and save context
|
||||||
|
|||||||
@@ -105,6 +105,12 @@ namespace AyaNova.Biz
|
|||||||
internal async Task<PurchaseOrder> GetAsync(long id, bool logTheGetEvent = true)
|
internal async Task<PurchaseOrder> GetAsync(long id, bool logTheGetEvent = true)
|
||||||
{
|
{
|
||||||
var ret = await ct.PurchaseOrder.Include(z => z.Items).AsNoTracking().SingleOrDefaultAsync(z => z.Id == id);
|
var ret = await ct.PurchaseOrder.Include(z => z.Items).AsNoTracking().SingleOrDefaultAsync(z => z.Id == id);
|
||||||
|
|
||||||
|
//populate names for client ui
|
||||||
|
var pl= new PickListBiz(ct,UserId,UserTranslationId,CurrentUserRoles);
|
||||||
|
foreach(PurchaseOrderItem item in ret.Items){
|
||||||
|
item.PartName= await pl.GetPickListAsync()
|
||||||
|
}
|
||||||
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;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
namespace AyaNova.Models
|
namespace AyaNova.Models
|
||||||
{
|
{
|
||||||
@@ -30,6 +30,9 @@ namespace AyaNova.Models
|
|||||||
public long? PurchaseTaxCodeId { get; set; }
|
public long? PurchaseTaxCodeId { get; set; }
|
||||||
public string VendorPartNumber { get; set; }
|
public string VendorPartNumber { get; set; }
|
||||||
|
|
||||||
|
//mirror name fields to save a roundtrip to the UI, not persisted
|
||||||
|
[NotMapped]
|
||||||
|
public string PartName { get; set; }
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public PurchaseOrder PurchaseOrder { get; set; }
|
public PurchaseOrder PurchaseOrder { get; set; }
|
||||||
|
|||||||
Reference in New Issue
Block a user