diff --git a/server/AyaNova/Controllers/PickListController.cs b/server/AyaNova/Controllers/PickListController.cs index 8e2ac8d8..4a9ffa32 100644 --- a/server/AyaNova/Controllers/PickListController.cs +++ b/server/AyaNova/Controllers/PickListController.cs @@ -76,27 +76,7 @@ namespace AyaNova.Api.Controllers if (!ModelState.IsValid) return BadRequest(new ApiErrorResponse(ModelState)); - //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 - /* - string TagSpecificQuery=string.Empty; - - //determine if this is a tag query - if(HasAutoCompleteQuery){ - if(autoCompleteQuery.Contains(" ")){ - //split the query on space - var querySegments=autoCompleteQuery.Split(' '); - //users may type several spaces in a regular query, so ignore that and only use the first two segments - if(querySegments[0].Contains("..")){ - TagSpecificQuery=querySegments[0].Replace("..",""); - //the second string is considered the - autoCompleteQuery=querySegments[1]; - }else{ - - } - - } - } - */ + var UserRoles = UserRolesFromContext.Roles(HttpContext.Items); diff --git a/server/AyaNova/PickList/PickListFetcher.cs b/server/AyaNova/PickList/PickListFetcher.cs index e86ec823..63aa4f28 100644 --- a/server/AyaNova/PickList/PickListFetcher.cs +++ b/server/AyaNova/PickList/PickListFetcher.cs @@ -17,7 +17,7 @@ namespace AyaNova.PickList { - internal static async Task> GetResponseAsync(AyaType ayaType, string autoCompleteQuery, bool includeInactive, AyContext ct, AuthorizationRoles userRoles) + internal static async Task> GetResponseAsync(AyaType ayaType, string autoCompleteQuery, string tagSpecificQuery, bool includeInactive, AyContext ct, AuthorizationRoles userRoles) { var PickList = PickListFactory.GetAyaPickList(ayaType); @@ -55,7 +55,7 @@ namespace AyaNova.PickList //BUILD THE QUERY - var q = PickListSqlBuilder.Build(PickList, TemplateColumnNames, autoCompleteQuery, includeInactive); + var q = PickListSqlBuilder.Build(PickList, TemplateColumnNames, autoCompleteQuery, tagSpecificQuery, includeInactive); diff --git a/server/AyaNova/biz/PickListBiz.cs b/server/AyaNova/biz/PickListBiz.cs index cc3da8f9..3acbb491 100644 --- a/server/AyaNova/biz/PickListBiz.cs +++ b/server/AyaNova/biz/PickListBiz.cs @@ -58,8 +58,43 @@ namespace AyaNova.Biz //get picklist internal async Task> GetPickListAsync(AyaType ayaType, string query, bool inactive, AuthorizationRoles userRoles) { + //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; - List items = await PickListFetcher.GetResponseAsync(ayaType, query, inactive, ct, userRoles); + //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) + { + if (AutoCompleteQuery.Contains(" ")) + { + // split the query on space + var querySegments = AutoCompleteQuery.Split(' '); + // users may type several spaces in a regular query, so ignore that and only use the first two segments + if (querySegments[0].Contains("..")) + { + TagSpecificQuery = querySegments[0].Replace("..", ""); + // the second string is considered the + AutoCompleteQuery = querySegments[1]; + } + else + { + + } + + } + else + { + //just a regular query + } + } + + + + List items = await PickListFetcher.GetResponseAsync(ayaType, AutoCompleteQuery, TagSpecificQuery, inactive, ct, userRoles); return items; }