Exemple #1
0
        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 }));
            }
        }
Exemple #2
0
        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 }));
            }
        }
Exemple #3
0
        public TagDto AddTag(ArticleTagDto dto)
        {
            var t = _articleTagDomainService.Add(Mapper.Map <ArticleTag>(dto));

            return(Mapper.Map <TagDto>(t));
        }
Exemple #4
0
        public IActionResult RemoveTag(ArticleTagDto dto)

        {
            _articleAppService.DeleteTag(dto.ArticleId, dto.TagId);
            return(RedirectToAction("Index"));
        }