This commit is contained in:
2018-09-20 18:42:45 +00:00
parent bbed6233cd
commit 5c01bbfe0f
2 changed files with 31 additions and 7 deletions

View File

@@ -49,6 +49,20 @@ namespace AyaNova.Biz
_ayaType = (AyaType)Enum.Parse(typeof(AyaType), sObjectTypeNumeral); _ayaType = (AyaType)Enum.Parse(typeof(AyaType), sObjectTypeNumeral);
} }
public bool Equals(AyaTypeId x, AyaTypeId y)
{
//Check whether the compared objects reference the same data.
if (Object.ReferenceEquals(x, y)) return true;
//Check whether any of the compared objects is null.
if (Object.ReferenceEquals(x, null) || Object.ReferenceEquals(y, null))
return false;
//Check whether the products' properties are equal.
return x.ObjectId == y.ObjectId && x.ObjectType == y.ObjectType;
}
public bool IsEmpty public bool IsEmpty
{ {
get get
@@ -96,7 +110,8 @@ namespace AyaNova.Biz
}
}//eoc
}//eons }//eons

View File

@@ -198,6 +198,8 @@ namespace AyaNova.Biz
//IF TAGS SPECIFIED //IF TAGS SPECIFIED
if (searchParameters.Tags.Count > 0) if (searchParameters.Tags.Count > 0)
{ {
//get a count of the search tags (used by both paths below)
var SearchTagCount = searchParameters.Tags.Count;
if (string.IsNullOrWhiteSpace(searchParameters.Phrase)) if (string.IsNullOrWhiteSpace(searchParameters.Phrase))
{ {
@@ -232,7 +234,7 @@ namespace AyaNova.Biz
var ShortList = await ct.TagMap.Where(x => x.TagId == ShortestMatchingTag).ToListAsync(); var ShortList = await ct.TagMap.Where(x => x.TagId == ShortestMatchingTag).ToListAsync();
//4) Iterate the shortlist and see if each item matches all other tags specified if it does then put it into the matching objects list for return //4) Iterate the shortlist and see if each item matches all other tags specified if it does then put it into the matching objects list for return
var SearchTagCount = searchParameters.Tags.Count;
//Iterate shortlist //Iterate shortlist
foreach (TagMap t in ShortList) foreach (TagMap t in ShortList)
{ {
@@ -262,7 +264,7 @@ namespace AyaNova.Biz
} }
else else
{ {
#region TAGS PLUS PHRASE SEARCH NONE MATCHING TAGS ARE EXCLUSIVE #region TAGS PLUS PHRASE SEARCH WITH NON MATCHING TAGS EXCLUSIVE
//list to hold temporary matches //list to hold temporary matches
List<AyaTypeId> TagMatchingObjects = new List<AyaTypeId>(); List<AyaTypeId> TagMatchingObjects = new List<AyaTypeId>();
@@ -270,12 +272,16 @@ namespace AyaNova.Biz
foreach (AyaTypeId i in MatchingObjects) foreach (AyaTypeId i in MatchingObjects)
{ {
var matchCount = await ct.TagMap.Where(x => x.TagToObjectId == i.ObjectId && x.TagToObjectType == i.ObjectType && searchParameters.Tags.Contains(x.TagId)).LongCountAsync(); var matchCount = await ct.TagMap.Where(x => x.TagToObjectId == i.ObjectId && x.TagToObjectType == i.ObjectType && searchParameters.Tags.Contains(x.TagId)).LongCountAsync();
if (matchCount == SearchTagCount)
{
TagMatchingObjects.Add(i);
}
} }
//FOREACH OBJECT SEARCH TAGMAP FOR MATCHING ALL TAGS FOR OBJECTTYPE AND ID //Ok here we have all the MatchingObjects that had all the tags in the TagMatchingObjects list so that's actually now our defacto return list
//IF NOT MATCH THEN REMOVE MatchingObjects = TagMatchingObjects;
//REMOVE RESULTS FROM SEARCH PHRASE PHASE THAT ARE NOT MATCHING
#endregion #endregion
@@ -283,7 +289,10 @@ namespace AyaNova.Biz
} }
//REMOVE ANY ITEMS THAT USER IS NOT PERMITTED TO READ //REMOVE ANY ITEMS THAT USER IS NOT PERMITTED TO READ
//TODO: this foreach (AyaTypeId t in MatchingObjects)
{
}
//amost ready to return, now populate the return list //amost ready to return, now populate the return list