public ActionResult <List <Article> > Search(SearchArticleInput input) { try { var articles = _repositoryFactory.ArticleRepository.Search(input).ToList(); var authors = _repositoryFactory.AuthorRepository.Search(input); foreach (var author in authors) { var articlesOfAuthor = _repositoryFactory.ArticleRepository.Search(new SearchArticleInput { AuthorId = author.Id }); foreach (var item in articlesOfAuthor) { if (articles.Any(a => a.Id != item.Id)) { articles.Add(item); } } } var viewModels = _mapper.Map <List <Article> >(articles); viewModels.ForEach(viewModel => { getArticleDetails(viewModel); }); return(viewModels); } catch (Exception ex) { var messageResponse = _errorGenerator.GetMessageResponse <Article, SearchArticleInput>(ActionType.List, input, ex); Log.Error(messageResponse.LogTemplate, messageResponse.Message, input); throw new Exception(messageResponse.Message); } }
public IEnumerable <Article> Search(SearchArticleInput input) { var parameters = new { CreateDateStart = input.CreateDateInterval?.Start, CreateDateEnd = input.CreateDateInterval?.End, UpdateDateStart = input.UpdateDateInterval?.Start, UpdateDateEnd = input.UpdateDateInterval?.End, input.QueryText, input.AuthorId, input.TagId, input.State }; return(base.Search(parameters)); }
public ActionResult <List <Article> > Search(SearchArticleInput input) { try { var dataModels = _articleRepository.Search(input); var viewModels = _mapper.Map <List <Article> >(dataModels); viewModels.ForEach(viewModel => { // getArticleDetails(viewModel); }); return(viewModels); } catch (Exception ex) { var messageResponse = _errorGenerator.GetMessageResponse <Article, SearchArticleInput>(ActionType.List, input, ex); Log.Error(messageResponse.LogTemplate, messageResponse.Message, input); throw new Exception(messageResponse.Message); } }