public IHttpActionResult Post(PostReplyToComment reply) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateReplyService(); if (!service.ReplyOnComment(reply)) { return(InternalServerError()); } return(Ok()); }
public bool ReplyOnComment(PostReplyToComment model) { var replyToCreate = new Reply() { ReplyId = model.ReplyId, Text = model.Text, Author = model.Author, CommentId = model.CommentId }; using (var ctx = new ApplicationDbContext()) { ctx.Replies.Add(replyToCreate); return(ctx.SaveChanges() == 1); } }