Esempio n. 1
0
        public ActionResult EditComment(TicketCommentsModel editComment) {

            if (ModelState.IsValid) {
                // the Comments refers to the Model IdentityModels - public DbSet<Comment> Comments { get; set; }.
                if (!db.TicketCommentsData.Local.Any(c => c.Id == editComment.Id))
                    db.TicketCommentsData.Attach(editComment);

                db.Entry(editComment).Property(p => p.Comment).IsModified = true;
                editComment.UpdatedDate = System.DateTimeOffset.Now;

                db.SaveChanges();
            }
            return RedirectToAction("Details", new { id = editComment.TicketId });
        }
Esempio n. 2
0
        public ActionResult DeleteComment(TicketCommentsModel deleteComment) {

            if (ModelState.IsValid) {
                if (!db.TicketCommentsData.Local.Any(c => c.Id == deleteComment.Id))
                    db.TicketCommentsData.Attach(deleteComment);

                db.TicketCommentsData.Remove(deleteComment);
                db.SaveChanges();
            }
            return RedirectToAction("Details", new { id = deleteComment.TicketId });
        }
Esempio n. 3
0
 public ActionResult AddComment(TicketCommentsModel newComment) {
     if (ModelState.IsValid) {
         newComment.CreatedDate = System.DateTimeOffset.Now;
         newComment.UpdatedDate = null;
         newComment.UserId = User.Identity.GetUserId();
         db.TicketCommentsData.Add(newComment);
         db.SaveChanges();
     }
     return RedirectToAction("Details", new { id = newComment.TicketId });
 }