Beispiel #1
0
        public async Task <GetArticlesResponse> GetArticlesAsync(GetArticlesRequest request)
        {
            var response = new GetArticlesResponse();

            try
            {
                response.Articles = await this.articleVersionRepository.GetAsync(q => q
                                                                                 .Where(x => x.LanguageId == request.LanguageId && x.IsPublished == true)
                                                                                 .OrderBy(x => x.Title)
                                                                                 .Select(x => new ArticleSummaryDto
                {
                    Id    = x.ArticleId,
                    Title = x.Title
                })
                                                                                 );

                response.Status = StatusCode.OK;
            }
            catch (Exception ex)
            {
                this.exceptionHandler.HandleException(ex);
                response.Status = StatusCode.InternalServerError;
            }

            return(response);
        }
Beispiel #2
0
        public async Task <GetArticlesResponse> GetEditArticlesAsync(GetArticlesRequest request)
        {
            var response = new GetArticlesResponse();

            try
            {
                response.Articles = await this.articleRepository.GetAsync(q => q
                                                                          .SelectMany(a => a.ArticleVersions
                                                                                      .Where(l => l.LanguageId == request.LanguageId)
                                                                                      .DefaultIfEmpty(a.ArticleVersions.Where(x => x.LanguageId == 1).FirstOrDefault()
                                                                                                      ),
                                                                                      (a, av) => new ArticleSummaryDto
                {
                    Id    = a.Id,
                    Title = av.Title
                })
                                                                          );

                response.Status = StatusCode.OK;
            }
            catch (Exception ex)
            {
                this.exceptionHandler.HandleException(ex);
                response.Status = StatusCode.InternalServerError;
            }

            return(response);
        }
Beispiel #3
0
        public async Task<GetArticlesResponse> GetArticlesAsync(GetArticlesRequest request)
        {
            var response = new GetArticlesResponse();

            try
            {
                response.Articles = await this.articleVersionRepository.GetAsync(q => q
                    .Where(x => x.LanguageId == request.LanguageId && x.IsPublished == true)
                    .OrderBy(x => x.Title)
                    .Select(x => new ArticleSummaryDto
                    {
                        Id = x.ArticleId,
                        Title = x.Title
                    })
                );

                response.Status = StatusCode.OK;
            }
            catch (Exception ex)
            {
                this.exceptionHandler.HandleException(ex);
                response.Status = StatusCode.InternalServerError;
            }

            return response;
        }
        public GetArticlesResponse GetArticles()
        {
            var response = new GetArticlesResponse();

            var entities = _articleRepository.GetArticlesInclude(x => x.Comments);

            response.Articles = Mapper.Map <IEnumerable <Dto.Article> >(entities);

            return(response);
        }
Beispiel #5
0
        public async Task<GetArticlesResponse> GetEditArticlesAsync(GetArticlesRequest request)
        {
            var response = new GetArticlesResponse();

            try
            {
                response.Articles = await this.articleRepository.GetAsync(q => q
                    .SelectMany(a => a.ArticleVersions
                        .Where(l => l.LanguageId == request.LanguageId)
                        .DefaultIfEmpty(a.ArticleVersions.Where(x => x.LanguageId == 1).FirstOrDefault()
                    ),
                    (a, av) => new ArticleSummaryDto
                    {
                        Id = a.Id,
                        Title = av.Title
                    })
                 );

                response.Status = StatusCode.OK;
            }
            catch (Exception ex)
            {
                this.exceptionHandler.HandleException(ex);
                response.Status = StatusCode.InternalServerError;
            }

            return response;
        }