This commit is contained in:
@@ -79,6 +79,8 @@ namespace AyaNova.Api.Controllers
|
|||||||
PickListBiz biz = PickListBiz.GetBiz(ct, HttpContext);
|
PickListBiz biz = PickListBiz.GetBiz(ct, HttpContext);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//handle HeadOffice only restricted variants
|
//handle HeadOffice only restricted variants
|
||||||
if (pickListParams.ListVariant == "ho")
|
if (pickListParams.ListVariant == "ho")
|
||||||
{
|
{
|
||||||
@@ -94,7 +96,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var o = await biz.GetPickListAsync(PickList, pickListParams.Query, pickListParams.Inactive, pickListParams.PreselectedIds.ToArray(), pickListParams.ListVariant, log);
|
var o = await biz.GetPickListAsync(PickList, pickListParams.Query, pickListParams.Inactive, pickListParams.PreselectedIds.ToArray(), pickListParams.ListVariant, log, pickListParams.Template);
|
||||||
if (o == null)
|
if (o == null)
|
||||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||||
else
|
else
|
||||||
@@ -123,7 +125,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
//Instantiate the business object handler
|
//Instantiate the business object handler
|
||||||
PickListBiz biz = PickListBiz.GetBiz(ct, HttpContext);
|
PickListBiz biz = PickListBiz.GetBiz(ct, HttpContext);
|
||||||
|
|
||||||
var o = await biz.GetTemplatedNameAsync(pickListSingleParams.AyaType, pickListSingleParams.Id, pickListSingleParams.ListVariant, log);
|
var o = await biz.GetTemplatedNameAsync(pickListSingleParams.AyaType, pickListSingleParams.Id, pickListSingleParams.ListVariant, log, pickListSingleParams.Template);
|
||||||
if (o == null)
|
if (o == null)
|
||||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -11,20 +11,27 @@ namespace AyaNova.PickList
|
|||||||
internal static class PickListFetcher
|
internal static class PickListFetcher
|
||||||
{
|
{
|
||||||
internal static async Task<List<NameIdActiveItem>> GetResponseAsync(IAyaPickList PickList, string autoCompleteQuery,
|
internal static async Task<List<NameIdActiveItem>> GetResponseAsync(IAyaPickList PickList, string autoCompleteQuery,
|
||||||
string tagSpecificQuery, bool includeInactive, long[] preIds, string variant, AyContext ct, ILogger log)
|
string tagSpecificQuery, bool includeInactive, long[] preIds, string variant, AyContext ct, ILogger log, string overrideTemplate)
|
||||||
{
|
{
|
||||||
|
|
||||||
//Sort out effective Template
|
//Sort out effective Template
|
||||||
string Template = null;
|
string Template = null;
|
||||||
//Attempt to fetch custom template
|
if (string.IsNullOrWhiteSpace(overrideTemplate))
|
||||||
var t = await ct.PickListTemplate.FirstOrDefaultAsync(z => z.Id == ((long)PickList.DefaultListAType));
|
|
||||||
if (t == null)
|
|
||||||
{
|
{
|
||||||
Template = PickList.DefaultTemplate;
|
//Attempt to fetch custom template
|
||||||
|
var t = await ct.PickListTemplate.FirstOrDefaultAsync(z => z.Id == ((long)PickList.DefaultListAType));
|
||||||
|
if (t == null)
|
||||||
|
{
|
||||||
|
Template = PickList.DefaultTemplate;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Template = t.Template;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Template = t.Template;
|
Template = overrideTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
//parse the template
|
//parse the template
|
||||||
@@ -77,7 +84,7 @@ namespace AyaNova.PickList
|
|||||||
log.LogError(e, "DB Exception");
|
log.LogError(e, "DB Exception");
|
||||||
throw new System.Exception("PickListFetcher - Query failed see log");
|
throw new System.Exception("PickListFetcher - Query failed see log");
|
||||||
}
|
}
|
||||||
catch (System.Exception e)
|
catch (System.Exception e)
|
||||||
{
|
{
|
||||||
//ensure any other type of exception gets surfaced properly
|
//ensure any other type of exception gets surfaced properly
|
||||||
//log out the exception and the query
|
//log out the exception and the query
|
||||||
|
|||||||
@@ -32,6 +32,9 @@ namespace AyaNova.PickList
|
|||||||
[FromBody]
|
[FromBody]
|
||||||
public string ListVariant { get; set; }
|
public string ListVariant { get; set; }
|
||||||
|
|
||||||
|
[FromBody]
|
||||||
|
public string Template { get; set; }
|
||||||
|
|
||||||
public PickListOptions()
|
public PickListOptions()
|
||||||
{
|
{
|
||||||
AyaType = AyaType.NoType;
|
AyaType = AyaType.NoType;
|
||||||
@@ -39,6 +42,7 @@ namespace AyaNova.PickList
|
|||||||
Inactive = false;
|
Inactive = false;
|
||||||
PreselectedIds = new List<long>();
|
PreselectedIds = new List<long>();
|
||||||
ListVariant = string.Empty;
|
ListVariant = string.Empty;
|
||||||
|
Template = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,11 +58,15 @@ namespace AyaNova.PickList
|
|||||||
[FromBody]
|
[FromBody]
|
||||||
public string ListVariant { get; set; }
|
public string ListVariant { get; set; }
|
||||||
|
|
||||||
|
[FromBody]
|
||||||
|
public string Template { get; set; }
|
||||||
|
|
||||||
public PickListSingleOptions()
|
public PickListSingleOptions()
|
||||||
{
|
{
|
||||||
AyaType = AyaType.NoType;
|
AyaType = AyaType.NoType;
|
||||||
Id = 0;
|
Id = 0;
|
||||||
ListVariant = string.Empty;
|
ListVariant = string.Empty;
|
||||||
|
Template = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
|
|
||||||
//get picklist
|
//get picklist
|
||||||
internal async Task<List<NameIdActiveItem>> GetPickListAsync(IAyaPickList PickList, string query, bool inactive, long[] preIds, string variant, ILogger log)
|
internal async Task<List<NameIdActiveItem>> GetPickListAsync(IAyaPickList PickList, string query, bool inactive, long[] preIds, string variant, ILogger log, string template)
|
||||||
{
|
{
|
||||||
|
|
||||||
//Crack and validate the query part set a broken rule if not valid and return null
|
//Crack and validate the query part set a broken rule if not valid and return null
|
||||||
@@ -134,14 +134,14 @@ 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, template);
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//get picklist display for a single item
|
//get picklist display for a single item
|
||||||
//used to populate UI with picklist format display for items
|
//used to populate UI with picklist format display for items
|
||||||
internal async Task<string> GetTemplatedNameAsync(AyaType ayaType, long id, string variant, ILogger log)
|
internal async Task<string> GetTemplatedNameAsync(AyaType ayaType, long id, string variant, ILogger log, string template)
|
||||||
{
|
{
|
||||||
//short circuit for empty types
|
//short circuit for empty types
|
||||||
if (id == 0)
|
if (id == 0)
|
||||||
@@ -155,7 +155,7 @@ namespace AyaNova.Biz
|
|||||||
log = AyaNova.Util.ApplicationLogging.CreateLogger("PickListBiz::GetTemplatedNameAsync");
|
log = AyaNova.Util.ApplicationLogging.CreateLogger("PickListBiz::GetTemplatedNameAsync");
|
||||||
|
|
||||||
//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, null, null, true, preIds, variant, ct, log);
|
List<NameIdActiveItem> items = await PickListFetcher.GetResponseAsync(PickList, null, null, true, preIds, variant, ct, log, template);
|
||||||
if (items.Count == 0)
|
if (items.Count == 0)
|
||||||
{
|
{
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
|
|||||||
Reference in New Issue
Block a user