Esempio n. 1
0
        public async Task <IActionResult> GetAllArticles()
        {
            var query    = new GetAllArticlesQuery();
            var response = await _mediator.Send(query);

            return(response.ToActionResult());
        }
        public async Task <IEnumerable <Article> > Handle(GetAllArticlesQuery query, CancellationToken cancellationToken)
        {
            Task <IEnumerable <Article> > articles = _articleRepository.GetAllArticles();

            if (articles.Result == null)
            {
                return(null);
            }
            return(await articles);
        }
Esempio n. 3
0
        public async Task <IActionResult> GetAllArticles(GetAllArticlesQuery query)
        {
            var result = await _mediator.Send(query);

            if (result.ErrorOccurred)
            {
                return(BadRequest(result));
            }

            return(Ok(result));
        }
Esempio n. 4
0
        public async Task <IActionResult> GetArticles()
        {
            FirebaseUser        user  = HttpContext.GetFirebaseUser();
            GetAllArticlesQuery model = new GetAllArticlesQuery()
            {
                firebaseId = user.UserId
            };
            ResultWrapper <GetAllArticlesOutput> result = new ResultWrapper <GetAllArticlesOutput>();

            result = await _mediator.Send(model);

            return(Ok(result));
        }
Esempio n. 5
0
        public async Task <ResultWrapper <GetAllArticlesOutput> > Handle(GetAllArticlesQuery request, CancellationToken cancellationToken)
        {
            ResultWrapper <GetAllArticlesOutput> result = new ResultWrapper <GetAllArticlesOutput>();

            var tDataList = await _dbContext.TArticle.ToListAsync();

            var list = tDataList.Select(x => new PublicListItem()
            {
                Enabled  = x.Enabled,
                Selected = false,
                Text     = x.Title,
                Value    = x.Id.ToString(),
                Image    = string.Empty
            })
                       .ToList();

            result.Status = true;
            result.Result = new GetAllArticlesOutput()
            {
                list = list
            };

            return(result);
        }
        public async Task <IEnumerable <Articles> > GetAllArticles()
        {
            var LQuery = new GetAllArticlesQuery();

            return(await FMediator.Send(LQuery));
        }
Esempio n. 7
0
 public async Task <IEnumerable <ArticleDto> > Handle(GetAllArticlesQuery request, CancellationToken cancellationToken)
 {
     return(_mapper.Map <IEnumerable <ArticleDto> >(await _dbContext.Articles.AsNoTracking().ToListAsync()));
 }
        Task <ResponseDto <GetAllArticlesViewModel> > IRequestHandler <GetAllArticlesQuery, ResponseDto <GetAllArticlesViewModel> > .Handle(GetAllArticlesQuery getArticlesQuery, CancellationToken cancellationToken)
        {
            var result         = new ResponseDto <GetAllArticlesViewModel>();
            var articlesFromDb = _articleTableStorageRepository.GetAllFromStorage();

            result.Object = new GetAllArticlesViewModel {
                Articles = articlesFromDb.Select(x => new GetAllArticlesSingleDto()
                {
                    PartitionKey = x.PartitionKey,
                    RowKey       = x.RowKey,
                    Content      = x.Content,
                    Title        = x.Title
                }).ToList()
            };

            return(Task.FromResult(result));
        }
Esempio n. 9
0
        async Task <ResponseDto <GetAllArticlesViewModel> > IRequestHandler <GetAllArticlesQuery, ResponseDto <GetAllArticlesViewModel> > .Handle(GetAllArticlesQuery getArticlesQuery, CancellationToken cancellationToken)
        {
            var result         = new ResponseDto <GetAllArticlesViewModel>();
            var articlesFromDb = await _articleRepository.GetAll();

            result.Object = new GetAllArticlesViewModel {
                Articles = articlesFromDb.Select(x => new GetAllArticlesSingleDto()
                {
                    Id       = x.Id,
                    Content  = x.Content,
                    Title    = x.Title,
                    Category = new ArticleCategory()
                    {
                        Id = x.Category.Id, Name = x.Category.Name
                    }
                }).ToList()
            };

            return(result);
        }
 public async Task <IEnumerable <Articles> > Handle(GetAllArticlesQuery ARequest, CancellationToken ACancellationToken)
 {
     return(await FCosmosDbService.GetItems <Articles>($"select * from {typeof(Articles).Name}", ACancellationToken));
 }