public async Task <IActionResult> DeleteArticle(Guid id) { var model = new ArticleDeleteDto() { Id = id }; await _articleService.DeleteAsync(model); return(NoContent()); }
public async Task DeleteAsync(ArticleDeleteDto dto) { if (dto.Id == Guid.Empty) { throw new ArticleException(ArticleErrorCodes.ArticleIdCannotBeNull, "Article Id field is mandatory.", dto); } var entity = await _articleRepository.GetByIdAsync(dto.Id); if (entity == null) { throw new ArticleException(ArticleErrorCodes.ArticleCouldNotBeFound, "Article could not be found.", dto); } // to do delete comments await _articleRepository.DeleteAsync(entity); }