This commit is contained in:
2021-09-09 00:06:16 +00:00
parent 220f185418
commit 4f70082d09
4 changed files with 31 additions and 14 deletions

View File

@@ -11,20 +11,27 @@ namespace AyaNova.PickList
internal static class PickListFetcher
{
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
string Template = null;
//Attempt to fetch custom template
var t = await ct.PickListTemplate.FirstOrDefaultAsync(z => z.Id == ((long)PickList.DefaultListAType));
if (t == null)
if (string.IsNullOrWhiteSpace(overrideTemplate))
{
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
{
Template = t.Template;
Template = overrideTemplate;
}
//parse the template
@@ -77,7 +84,7 @@ namespace AyaNova.PickList
log.LogError(e, "DB Exception");
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
//log out the exception and the query

View File

@@ -32,6 +32,9 @@ namespace AyaNova.PickList
[FromBody]
public string ListVariant { get; set; }
[FromBody]
public string Template { get; set; }
public PickListOptions()
{
AyaType = AyaType.NoType;
@@ -39,6 +42,7 @@ namespace AyaNova.PickList
Inactive = false;
PreselectedIds = new List<long>();
ListVariant = string.Empty;
Template = string.Empty;
}
}
@@ -54,11 +58,15 @@ namespace AyaNova.PickList
[FromBody]
public string ListVariant { get; set; }
[FromBody]
public string Template { get; set; }
public PickListSingleOptions()
{
AyaType = AyaType.NoType;
Id = 0;
ListVariant = string.Empty;
Template = string.Empty;
}
}