Ejemplo n.º 1
0
        public virtual ActionResult EditComment(string keyName, int id, Comment comment)
        {
            Ticket ticket = _ticketRepo.GetTicketByKey(keyName);
            Comment originalComment = _ticketRepo.GetCommentById(id);

            if (ticket == null ||
                originalComment == null ||
                originalComment.TicketId != ticket.Id ||
                originalComment.UserId != 1)
            {
                return RedirectToAction(MVC.Error.InvalidAction());
            }

            if (ModelState.IsValid)
            {
                originalComment.Body = comment.Body;
                originalComment.Modified = DateTime.Now;
                _ticketRepo.Save(originalComment);

                return RedirectToAction(MVC.Ticket.TicketDetails(keyName));
            }

            return View(new CommentCreateEditModel()
            {
                Comment = comment
            });
        }
Ejemplo n.º 2
0
        public virtual ActionResult CreateComment(string keyName, Comment comment)
        {
            Ticket ticket = _ticketRepo.GetTicketByKey(keyName);

            if (ticket == null)
            {
                return RedirectToAction(MVC.Error.InvalidAction());
            }

            if (ModelState.IsValid)
            {
                comment.Created = DateTime.Now;
                comment.Modified = DateTime.Now;
                comment.UserId = Auth.CurrentUser.Id;
                comment.TicketId = ticket.Id;
                _ticketRepo.Save(comment);

                return RedirectToAction(MVC.Ticket.TicketDetails(keyName));
            }

            CommentCreateEditModel viewData = new CommentCreateEditModel()
            {
                Comment = comment
            };

            return View(viewData);
        }