diff --git a/server/AyaNova/biz/AyaTypeId.cs b/server/AyaNova/biz/AyaTypeId.cs index 35acb6e1..95c7deb1 100644 --- a/server/AyaNova/biz/AyaTypeId.cs +++ b/server/AyaNova/biz/AyaTypeId.cs @@ -49,6 +49,20 @@ namespace AyaNova.Biz _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 { get @@ -96,7 +110,8 @@ namespace AyaNova.Biz - } + + }//eoc }//eons diff --git a/server/AyaNova/biz/Search.cs b/server/AyaNova/biz/Search.cs index cec30b51..16d1de6c 100644 --- a/server/AyaNova/biz/Search.cs +++ b/server/AyaNova/biz/Search.cs @@ -198,6 +198,8 @@ namespace AyaNova.Biz //IF TAGS SPECIFIED 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)) { @@ -232,7 +234,7 @@ namespace AyaNova.Biz 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 - var SearchTagCount = searchParameters.Tags.Count; + //Iterate shortlist foreach (TagMap t in ShortList) { @@ -262,7 +264,7 @@ namespace AyaNova.Biz } 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 TagMatchingObjects = new List(); @@ -270,12 +272,16 @@ namespace AyaNova.Biz 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(); + if (matchCount == SearchTagCount) + { + TagMatchingObjects.Add(i); + } } - //FOREACH OBJECT SEARCH TAGMAP FOR MATCHING ALL TAGS FOR OBJECTTYPE AND ID - //IF NOT MATCH THEN REMOVE - //REMOVE RESULTS FROM SEARCH PHRASE PHASE THAT ARE NOT MATCHING + //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 + MatchingObjects = TagMatchingObjects; + #endregion @@ -283,7 +289,10 @@ namespace AyaNova.Biz } //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