This commit is contained in:
2020-03-16 22:54:00 +00:00
parent cdfca271d3
commit b20882cb5e
3 changed files with 44 additions and 39 deletions

View File

@@ -7,7 +7,7 @@ using AyaNova.Util;
using AyaNova.Api.ControllerHelpers;
using AyaNova.Models;
using AyaNova.PickList;
using EnumsNET;
namespace AyaNova.Biz
{
@@ -56,21 +56,10 @@ namespace AyaNova.Biz
//get picklist
internal async Task<List<NameIdActiveItem>> GetPickListAsync(AyaType ayaType, string query, bool inactive, AuthorizationRoles userRoles)
internal async Task<List<NameIdActiveItem>> GetPickListAsync(IAyaPickList PickList, string query, bool inactive)
{
var PickList = PickListFactory.GetAyaPickList(ayaType);
//was the name not found as a pick list?
if (PickList == null)
{
//not a user error so no need to localize
AddError(ApiErrorCode.NOT_FOUND, "ayaType", $"PickList for type \"{ayaType}\" specified does not exist");
return null;
}
//Crack and validate the query part set a broken rule if not valid and return null
//else do the query
@@ -81,10 +70,12 @@ namespace AyaNova.Biz
//Here need to handle scenario of badly formed query so user knows they did it wrong and doesn't just assume it's not there
//determine if this is a tag query
bool HasAutoCompleteQuery = !string.IsNullOrWhiteSpace(query);
if (HasAutoCompleteQuery)
//determine if this is a tag query and extract it
bool HasQuery = !string.IsNullOrWhiteSpace(query);
if (HasQuery)
{
AutoCompleteQuery=query;
//is it a dual template and tag query?
if (AutoCompleteQuery.Contains(" "))
{
// split the query on space
@@ -114,13 +105,17 @@ namespace AyaNova.Biz
}
else
{
//just a regular query
//is it a tag only query?
if(AutoCompleteQuery.Contains("..")){
TagSpecificQuery=AutoCompleteQuery.Replace("..","");
AutoCompleteQuery=null;
}
}
}
//Autocomplete and tagonly query terms now set for consumption by PickListFetcher, ready to fetch...
List<NameIdActiveItem> items = await PickListFetcher.GetResponseAsync(ayaType, AutoCompleteQuery, TagSpecificQuery, inactive, ct, userRoles);
List<NameIdActiveItem> items = await PickListFetcher.GetResponseAsync(PickList, AutoCompleteQuery, TagSpecificQuery, inactive, ct);
return items;
}