public IHttpActionResult HashTagsMemes([FromBody] HashTagRequestModel requestModel) { List <IHashTag> similarHashTags = new List <IHashTag>(); List <HashTagMemeModel> memes = new List <HashTagMemeModel>(); foreach (string hashTag in requestModel.FilterList) { // Add the hashtag memes to the model memes = AddHashTagMemes(hashTag, requestModel.TakeMemes, memes); // Add other hash tags that are similar to this one to the model similarHashTags.AddRange(repository.SearchHashTags(hashTag, requestModel.TakeMemes).Select(x => { x.Id = WebUtility.HtmlEncode(x.Id); x.Name = WebUtility.HtmlEncode(x.Name); return(x); })); } // Sort similar HashTags descending by meme trend score similarHashTags = similarHashTags.OrderByDescending(x => x.TrendScoreOfAllMemes).ToList(); return(Ok(new { memes, similarHashTags = similarHashTags.Select(x => x.Name).Distinct().ToList() // Return only the string of the hash tag })); }
public IHttpActionResult TrendingHashTagMemes([FromBody] HashTagRequestModel requestModel) { List <HashTagMemeModel> model = new List <HashTagMemeModel>(); List <IHashTag> trendingHashTags = repository.SearchTrendingHashTags(requestModel.TakeHashTags); foreach (IHashTag trendingHashTag in trendingHashTags) { // If the list of hashtags is filtered then only include the tags in the filter if (requestModel.FilterList != null && requestModel.FilterList.Count > 0) { if (!requestModel.FilterList.Contains(trendingHashTag.Name)) { continue; } } // Retrieve the hmemes of the hash tag and add to the model model = AddHashTagMemes(WebUtility.HtmlEncode(trendingHashTag.Name), requestModel.TakeMemes, model); } return(Ok(model)); }