public IActionResult Create([FromBody] ArticleTagDto articleTagDto) { var articleTag = _mapper.Map <ArticleTag>(articleTagDto); try { _articleTagService.Create(articleTag); return(Ok()); } catch (AppException ex) { return(BadRequest(new { message = ex.Message })); } }
public IActionResult Update(int id, [FromBody] ArticleTagDto articleTagDto) { // map dto to entity and set id var articleTag = _mapper.Map <ArticleTag>(articleTagDto); articleTag.Id = id; try { // save _articleTagService.Update(articleTag); return(Ok()); } catch (AppException ex) { // return error message if there was an exception return(BadRequest(new { message = ex.Message })); } }
public TagDto AddTag(ArticleTagDto dto) { var t = _articleTagDomainService.Add(Mapper.Map <ArticleTag>(dto)); return(Mapper.Map <TagDto>(t)); }
public IActionResult RemoveTag(ArticleTagDto dto) { _articleAppService.DeleteTag(dto.ArticleId, dto.TagId); return(RedirectToAction("Index")); }