public async Task <IActionResult> Delete(ArticleForDeleteDto dto) { var result = await _articleService.Delete(dto); if (result.Success) { return(Ok(result)); } return(BadRequest(result)); }
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)); }
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)))); }