コード例 #1
0
        public async Task <IActionResult> Delete(ArticleForDeleteDto dto)
        {
            var result = await _articleService.Delete(dto);

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
コード例 #2
0
        public async Task <IResult> Delete(ArticleForDeleteDto dto)
        {
            var isExistsArticle = await _articleDal.GetAsync(a => a.Id == dto.Id);

            if (isExistsArticle == null)
            {
                return(new ErrorResult(Messages.ArticleNotFound));
            }
            await _articleDal.DeleteAsync(isExistsArticle);

            return(new SuccessResult(Messages.DeletedSuccessfully));
        }
コード例 #3
0
        public IResult DeleteArticle(ArticleForDeleteDto articleForDeleteDto)
        {
            //TO DO: Implement transaction

            var articleToBeDeleted = _mapper.Map <ArticleTranslation>(articleForDeleteDto);

            _articleTranslationRepository.Delete(articleToBeDeleted);
            var article = _articleRepository.GetIncluding(x => x.Id == articleForDeleteDto.Id, x => x.ArticleTranslations);

            if (article.ArticleTranslations.Count == 0)
            {
                var articleToBeSoftDeleted = _mapper.Map <Article>(article);
                _articleRepository.SoftDelete(articleToBeSoftDeleted);
            }
            return(new SuccessResult(string.Format(Messages.SuccessfulDelete, nameof(Article))));
        }