This commit is contained in:
2020-03-16 22:43:26 +00:00
parent fd63ad2320
commit cdfca271d3
6 changed files with 29 additions and 10 deletions

View File

@@ -58,11 +58,27 @@ namespace AyaNova.Biz
//get picklist
internal async Task<List<NameIdActiveItem>> GetPickListAsync(AyaType ayaType, string query, bool inactive, AuthorizationRoles userRoles)
{
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
string TagSpecificQuery = null;
string AutoCompleteQuery = null;
//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
@@ -75,7 +91,7 @@ namespace AyaNova.Biz
var querySegments = AutoCompleteQuery.Split(' ');
if (querySegments.Length > 2)
{
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "query", "LT:PickListQueryInvalid");
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "query", "LT:ErrorPickListQueryInvalid");
return null;
}
// users may type several spaces in a regular query, so ignore that and only use the first two segments
@@ -91,7 +107,7 @@ namespace AyaNova.Biz
}
else
{
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "query", "LT:PickListQueryInvalid");
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "query", "LT:ErrorPickListQueryInvalid");
return null;
}