Example #1
0
        public IActionResult TicketDetails(int ticketId)
        {
            var ticket      = _ticketServices.GetById(ticketId);
            var ticketModel = _ticketServices.FormatTicket(ticket);
            var model       = new TicketCommentModel
            {
                TicketModel  = ticketModel,
                CommentModel = new CommentModel()
            };

            return(View(model));
        }
Example #2
0
        public async Task <IActionResult> AddComment(TicketCommentModel model)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("TicketDetails", new { ticketId = model.TicketModel.Id }));
            }

            var ticket      = _ticketServices.GetById(model.TicketModel.Id);
            var currentUser = await _userManager.GetUserAsync(User);

            var newComment = new Comment
            {
                Message    = model.CommentModel.Message,
                Commenter  = currentUser,
                CreateDate = DateTime.Now,
                Ticket     = ticket
            };

            _context.Comments.Add(newComment);
            _context.SaveChanges();

            return(RedirectToAction("TicketDetails", new { ticketId = model.TicketModel.Id }));
        }