This commit is contained in:
2018-09-19 23:00:49 +00:00
parent 64d69442a5
commit e4b10b82ee
2 changed files with 23 additions and 7 deletions

View File

@@ -13,8 +13,7 @@ using AyaNova.Models;
namespace AyaNova.Biz
{
//TODO: UNTESTED, UNUSED (SO FAR)CODE
//This was just blocked out because I know I will need it in future
//Turn a type and ID into a displayable name
internal static class BizObjectNameFetcher
{

View File

@@ -170,17 +170,34 @@ namespace AyaNova.Biz
//SEARCH SEARCHKEY FOR MATCHING WORDS AND OPTIONALLY TYPE AND INNAME
List<SearchKey> SearchKeyMatches = new List<SearchKey>();
SearchKeyMatches = await ct.SearchKey.Where(m => DictionaryMatches.Contains(m.Id)).ToListAsync();
//Build search query based on searchParameters
var q = ct.SearchKey.Where(m => DictionaryMatches.Contains(m.Id));
//In name?
if (searchParameters.NameOnly)
q.Where(m => m.InName == true);
//Of type?
if (searchParameters.TypeOnly != AyaType.NoType)
q.Where(m => m.ObjectType == searchParameters.TypeOnly);
//Trigger the search
SearchKeyMatches = await q.ToListAsync();
//IF TAGS SPECIFIED
//LOOP THROUGH SEARCHKEY MATCHES
//FOREACH OBJECT SEARCH TAGMAP FOR MATCHING OBJECTTYPE AND ID
//REMOVE RESULTS FROM SEARCH PHRASE PHASE THAT ARE NOT MATCHING
//fake await to clear error
//await ct.SaveChangesAsync();
foreach (SearchKey SearchKeyMatch in SearchKeyMatches)
{
SearchResult SR = new SearchResult();
SR.Name = BizObjectNameFetcher.Name(SearchKeyMatch.ObjectType, SearchKeyMatch.ObjectId, ct);
SR.Id = SearchKeyMatch.ObjectId;
SR.Type = SearchKeyMatch.ObjectType;
ResultList.Add(SR);
}
return ResultList;
}