public bool Add(int id, ArticleCommentCreate articleCommentCreate)
        {
            var article = _articleRepository.Get(id);

            if (article == null)
            {
                throw new Exception("Błąd, brak artykułó");
            }

            article.Comments.Add(new ArticleComment(articleCommentCreate));

            return(_articleRepository.Update(article));
        }
        public bool Replace(int id, ArticleCommentCreate articleCommentCreate)
        {
            var comment = _commentRepository.Get(id);

            if (comment == null)
            {
                throw new Exception("Brak komentarza");
            }

            return(_commentRepository.Save(new Entites.ArticleComment(articleCommentCreate)
            {
                ArticleCommentId = id,
                ArticleId = comment.ArticleId
            }));
        }
Пример #3
0
        public IActionResult AddComment(int id, [FromBody] ArticleCommentCreate articleCommentCreate)
        {
            if (articleCommentCreate == null)
            {
                throw new ApiException("Błąd danych parametru");
            }

            if (!ModelState.IsValid)
            {
                throw new ApiValidationException("Walidacja");
            }

            if (!_articleCommentService.Add(id, articleCommentCreate))
            {
                throw new ApiException("Wystąpił bład podczas dodawania komentarza");
            }

            return(new ResponseObjectResult("Akcja wykonana porawnie"));
        }
Пример #4
0
        public IActionResult Add([FromBody] ArticleCommentCreate commentCreate, int id)
        {
            if (commentCreate == null)
            {
                throw new ApiException("Błąd danych parametru");
            }

            if (!ModelState.IsValid)
            {
                throw new ApiValidationException("Walidacja");
            }

            if (!_commentService.Replace(id, commentCreate))
            {
                throw new ApiException("Bład wykonano akcji dopowiedzi na komentarz");
            }

            return(new ResponseObjectResult("Pomyślnie wykonano akcje dopowiedzi na komentarz"));
        }
Пример #5
0
 public ArticleComment(ArticleCommentCreate articleCommentCreate)
 {
     Surname     = articleCommentCreate.FirstName;
     Description = articleCommentCreate.Description;
     CreatedAt   = DateTime.Now;
 }
 public bool Save(ArticleCommentCreate value)
 {
     throw new NotImplementedException();
 }