/// <summary> /// The search blogs. /// </summary> /// <param name="parameters"> /// The parameters. /// </param> /// <returns> /// The search results. /// </returns> private IQueryable<AddressableContentBase> SearchBlogs(SearchParameters parameters) { var keywordSpecification = this.blogSpecificationFactory.GetNullSpecification(); if (!string.IsNullOrEmpty(parameters.Keywords)) { keywordSpecification = this.blogSpecificationFactory.GetKeywordSpecification(parameters.Keywords); } var dateFromSpecification = this.blogSpecificationFactory.GetNullSpecification(); if (parameters.DateFrom.HasValue) { dateFromSpecification = this.blogSpecificationFactory.GetDateFromSpecification( parameters.DateFrom.Value); } var dateToSpecification = this.blogSpecificationFactory.GetNullSpecification(); if (parameters.DateTo.HasValue) { dateToSpecification = this.blogSpecificationFactory.GetDateToSpecification(parameters.DateTo.Value); } var searchSpecification = this.blogSpecificationBuilder .Using(keywordSpecification) .And(dateFromSpecification) .And(dateToSpecification) .ToSpecification(); return this.blogRepository .FindAll(searchSpecification) .OrderByDescending(x => x.CreationDate) .Cast<AddressableContentBase>(); }
/// <summary> /// The search. /// </summary> /// <param name="parameters"> /// The parameters. /// </param> /// <returns> /// The search results. /// </returns> public IQueryable<AddressableContentBase> Search(SearchParameters parameters) { if (!parameters.IsEmpty()) { switch (parameters.ContentType) { case SearchContentType.Blog: return this.SearchBlogs(parameters); case SearchContentType.Post: return this.SearchBlogPosts(parameters); case SearchContentType.Any: return this.SearchAny(parameters); } } return new List<AddressableContentBase>().AsQueryable(); }
/// <summary> /// The search any. /// </summary> /// <param name="parameters"> /// The parameters. /// </param> /// <returns> /// The search results. /// </returns> private IQueryable<AddressableContentBase> SearchAny(SearchParameters parameters) { var searchResults = new List<AddressableContentBase>(); searchResults.AddRange(this.SearchBlogs(parameters)); searchResults.AddRange(this.SearchBlogPosts(parameters)); return searchResults.AsQueryable(); }