public bool UpdateReply(EditAReply model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var replyToUpdate =
                    ctx
                    .Replies
                    .Single(e => e.ReplyId == model.ReplyId && e.UserId == _userId);

                replyToUpdate.ReplyText = model.ReplyText;
                return(ctx.SaveChanges() == 1);
            }
        }
Beispiel #2
0
        public IHttpActionResult Put(EditAReply replyToEdit)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateReplyService();

            if (!service.UpdateReply(replyToEdit))
            {
                return(InternalServerError());
            }

            return(Ok());
        }