async Task <ResponseDto <GetArticleViewModel> > IRequestHandler <GetArticleQuery, ResponseDto <GetArticleViewModel> > .Handle(GetArticleQuery getArticleQuery, CancellationToken cancellationToken)
        {
            var result        = new ResponseDto <GetArticleViewModel>();
            var articleFromDb = await _articleTableStorageRepository.GetOneFromStorage(getArticleQuery.PartitionKey, getArticleQuery.RowKey);

            if (articleFromDb == null)
            {
                result.Errors.Add("Article not found");
                return(result);
            }
            result.Object = new GetArticleViewModel()
            {
                PartitionKey = articleFromDb.PartitionKey,
                RowKey       = articleFromDb.RowKey,
                Content      = articleFromDb.Content,
                Title        = articleFromDb.Title
            };

            return(result);
        }
Esempio n. 2
0
        async Task <ResponseDto <GetArticleViewModel> > IRequestHandler <GetArticleQuery, ResponseDto <GetArticleViewModel> > .Handle(GetArticleQuery getArticleQuery, CancellationToken cancellationToken)
        {
            var result        = new ResponseDto <GetArticleViewModel>();
            var articleFromDb = await _articleRepository.Get(getArticleQuery.Id);

            result.Object = new GetArticleViewModel()
            {
                Id       = articleFromDb.Id,
                Content  = articleFromDb.Content,
                Title    = articleFromDb.Title,
                Category = articleFromDb.Category
            };

            return(result);
        }