Ejemplo n.º 1
0
 public IActionResult Post([FromBody] Comment comment)
 {
     try
     {
         if (_commentManager.Validate(comment))
         {
             _commentManager.Save(comment);
         }
         return(Ok());
     }
     catch (PostNotFound e)
     {
         return(BadRequest(e.Data));
     }
     catch (AuthorNotFound e)
     {
         return(BadRequest(e.Data));
     }
 }
Ejemplo n.º 2
0
        public override int Save(CardDTO dto)
        {
            var unsavedComments = dto.Comments.Where(x => x.Id == 0).ToList();

            dto.Comments.ToList().RemoveAll(x => x.Id == 0);

            foreach (var comment in unsavedComments)
            {
                comment.Id = _commentManager.Save(comment);
            }

            dto.Comments.ToList().AddRange(unsavedComments);

            return(base.Save(dto));
        }