Beispiel #1
0
        public bool UpdateReply(ReplyEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity = ctx.Replies.Single(e => e.ReplyId == model.ReplyId && e.UserId == _userId);

                entity.ReplyText = model.ReplyText;

                return(ctx.SaveChanges() == 1);
            }
        }
Beispiel #2
0
        //EDIT REPLY
        public bool EditReply(ReplyEdit model)
        {
            using (var db = new ApplicationDbContext())
            {
                var entity = db.Replies.Single(e => e.ID == model.ID && e.UserID == _userId);
                entity.Body       = model.Body;
                entity.TimeEdited = DateTimeOffset.Now;

                return(db.SaveChanges() == 1);
            }
        }
Beispiel #3
0
        public IHttpActionResult UpdateReply([FromUri] int id, [FromBody] ReplyEdit model)
        {
            var service = CreateReplyService();

            if (!service.UpdateReply(id, model))
            {
                return(InternalServerError());
            }

            return(Ok());
        }
        // GET: Reply/Edit/{id}
        public ActionResult Edit(int id)
        {
            var service = CreateReplyService();
            var detail  = service.GetReplyById(id);
            var model   = new ReplyEdit()
            {
                ReplyId   = detail.ReplyId,
                ReplyText = detail.ReplyText
            };

            return(View(model));
        }
Beispiel #5
0
        public bool UpdateReply(ReplyEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity = ctx
                             .Replies.Single(e => e.ReplyId == model.Id && e.Author == _userId);

                entity.Text        = model.Text;
                entity.ModifiedUtc = DateTimeOffset.UtcNow;

                return(ctx.SaveChanges() == 1);
            }
        }
        public IHttpActionResult Put(ReplyEdit reply)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var service = CreateReplyService();

            if (!service.UpdateReply(reply))
            {
                return(InternalServerError());
            }
            return(Ok());
        }
        public async Task <IHttpActionResult> EditReply(ReplyEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            ReplyService service = CreateReplyService();

            if (!await service.EditReply(model))
            {
                return(InternalServerError());
            }
            return(Ok());
        }
        public bool UpdateReply([FromUri] int id, [FromBody] ReplyEdit model)//put
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Replies
                    .Single(e => e.ReplyId == id && e.Author == _userId);

                entity.Text = model.Text;

                return(ctx.SaveChanges() == 1);
            }
        }
Beispiel #9
0
        //PUT
        public bool UpdateReply(ReplyEdit model)
        {
            using (var db = new ApplicationDbContext())
            {
                var reply = db.Replies.Single(e => e.OwnerId == _userId &&
                                              e.ReplyId == model.ReplyId);

                reply.Title    = model.Title;
                reply.Content  = model.Content;
                reply.Modified = DateTimeOffset.Now;

                return(db.SaveChanges() == 1);
            }
        }
Beispiel #10
0
        //update by ID
        public bool UpdateReply(ReplyEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Reply
                    .Single(e => e.ReplyId == _ReplyId);

                entity.Text   = model.Text;
                entity.Author = model.Author;

                return(ctx.SaveChanges() == 1);
            }
        }
        public bool UpdateReply(ReplyEdit replyToEdit)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Reply
                    .Single(e => e.CommentId == replyToEdit.CommentId && e.OwnerId == _userId);

                entity.Content    = replyToEdit.Content;
                entity.OwnerId    = replyToEdit.OwnerId;
                entity.CreatedUtc = DateTimeOffset.UtcNow;

                return(ctx.SaveChanges() == 1);
            }
        }
Beispiel #12
0
        public bool UpdateComment(ReplyEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var replyEntity = ctx.Replies.Single(p => p.ReplyId == model.ReplyId && p.ApplicationUserId == _userId.ToString());
                if (replyEntity == null)
                {
                    return(false);
                }

                replyEntity.Text        = model.Text;
                replyEntity.ModifiedUtc = DateTimeOffset.UtcNow;

                return(ctx.SaveChanges() == 1);
            }
        }
Beispiel #13
0
        public bool UpdateReply(ReplyEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Replies
                    .Single(e => e.CommentID == model.CommentID && e.UserID == _userID);
                entity.CommentID    = model.CommentID;
                entity.CommentText  = model.CommentText;
                entity.ReplyComment = model.ReplyComment;


                return(ctx.SaveChanges() == 1);
            }
        }
Beispiel #14
0
 public bool UpdateReply(ReplyEdit model)
 {
     using (var ctx = new ApplicationDbContext())
     {
         var entity =
             ctx
             .Replies
             .Single(e => e.ReplyID == model.ReplyID && e.UserID == _userID);
         entity.ReplyID    = model.ReplyID;
         entity.ReplyTitle = model.ReplyTitle;
         entity.ReplyText  = model.ReplyText;
         entity.UserID     = model.UserID;
         //entity.ModifiedUtc = DateTimeOffset.UtcNow;
         return(ctx.SaveChanges() == 1);
     }
 }
Beispiel #15
0
        // Update: Update/edit a reply
        public bool UpdateReply(ReplyEdit model, int id)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Replies
                    .Single(e => e.ReplyId == id);         //.Single(e => e.ReplyId == model.ReplyId);   // Once Owner is added: .Single(e => e.ReplyId == id && e.OwnerId == _userId); // OG: .Single(e => e.ReplyId == model.ReplyId && e.OwnerId == _userId);

                entity.ReplyText   = model.ReplyText;
                entity.ModifiedUtc = DateTimeOffset.UtcNow;
                //   entity.ReplyId = model.ReplyId;
                entity.TipId = model.TipId;


                return(ctx.SaveChanges() == 1);
            }
        }
        public ActionResult Edit(int id, ReplyEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.ReplyId != id)
            {
                ModelState.AddModelError("", "IDs do not match.");
                return(View(model));
            }

            var service = CreateReplyService();

            if (service.UpdateReply(model))
            {
                TempData["SaveResult"] = "Reply successfully updated";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Reply was not updated");
            return(View(model));
        }