public async Task BlogSearch(IDialogContext context, LuisResult result) { string tag = string.Empty; string replyText = string.Empty; List <Post> posts = new List <Post>(); try { if (result.Entities.Count > 0) { tag = result.Entities.FirstOrDefault(e => e.Type == "Tag").Entity; } if (!string.IsNullOrWhiteSpace(tag)) { var bs = new BlogSearch(); posts = bs.GetPostsWithTag(tag); } replyText = GenerateResponseForBlogSearch(posts, tag); await context.PostAsync(replyText); } catch (Exception) { await context.PostAsync("Something really bad happened. You can try again later meanwhile I'll check what went wrong."); } finally { context.Wait(MessageReceived); } }
public async Task <BlogSearch> SearchAsync(BlogSearch criteria) { var blogEntries = _dataContext.BlogEntries.AsQueryable(); if (!criteria.IncludeUnpublished) { blogEntries = blogEntries.Where(e => e.IsPublished); } if (!string.IsNullOrEmpty(criteria.Text)) { blogEntries = blogEntries.Match(criteria.Text, _keywordProcessor); } var index = int.Parse(criteria.Continuation); var results = await blogEntries .OrderBy(e => e.Title) .Skip(index * _searchSettings.PageSize) .Take(_searchSettings.PageSize + 1) .Select(InfoProjection) .ToListAsync(); criteria.NextContinuation = (results.Count() > _searchSettings.PageSize).ToString(); criteria.Results = results.Take(_searchSettings.PageSize); return(criteria); }
public async Task <BlogSearch> Get( [FromBody] BlogSearch model) { var results = await _readService.SearchAsync(model); return(model); }
public virtual BlogSearch ToLiquidBlogSearch(StorefrontModel.BlogSearchCriteria blogSearchCriteria) { var retVal = new BlogSearch(); retVal.InjectFrom <NullableAndEnumValueInjecter>(blogSearchCriteria); return(retVal); }
public virtual BlogSearch ToLiquidBlogSearch(StorefrontModel.BlogSearchCriteria blogSearchCriteria) { var retVal = new BlogSearch(); retVal.Author = blogSearchCriteria.Author; retVal.Category = blogSearchCriteria.Category; return(retVal); }
public async Task <DataSource <BlogInfo> > GetBlogInfos(BlogSearch blogSearch) { var blogs = await blogService.GetBlogs(blogSearch.Name, string.IsNullOrEmpty(blogSearch.TypeId)? 0 : long.Parse(blogSearch.TypeId)) .Select(a => new BlogInfo { Id = a.Id, Name = a.Name, BlogTypeId = a.BlogTypeId, TypeName = a.BlogType.TypeName }) .OrderByDescending(a => a.Id) .takePageDataAndCountAsync(blogSearch.Skip, blogSearch.Size); var res = new DataSource <BlogInfo> { Data = blogs.Data, Count = blogs.Count }; return(res); }
public async Task <DataSource <BlogInfo> > GetBlogInfos(BlogSearch blogSearch) { return(await blogApplication.GetBlogInfos(blogSearch)); }
/// <summary> /// Upserts the index of the data to. /// </summary> /// <param name="blogSearchEntity">The blog search entity.</param> /// <exception cref="BlogSystemException">failed on index</exception> /// <exception cref="RahulRai.Websites.Utilities.Common.Exceptions.BlogSystemException">failed on index</exception> public void UpsertDataToIndex(BlogSearch blogSearchEntity) { var documents = new[] { blogSearchEntity }; this.indexClient.Documents.Index(IndexBatch.Create(documents.Select(IndexAction.Create))); }