public IActionResult Service(NewLogServiceViewModel model)
        {
            //check model state
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            if (model.TicketStatus == TicketStatus.New)
            {
                model.TicketStatus = TicketStatus.InProgress;
            }
            var ticket = context.Tickets.Find(model.TicketId);
            Log log    = new Log
            {
                UserCreated  = User.FindFirst(ClaimTypes.Name).Value.ToString(),
                TicketId     = model.TicketId,
                DateCreated  = DateTime.Now,
                Notes        = model.LogNotes,
                EventId      = model.SelectedEventId,
                TicketStatus = model.TicketStatus
            };

            context.Add(log);
            //update the database with any changes that were made to the ticketstatus
            context.SaveChanges();
            return(RedirectToAction("Index", "Ticket"));
        }
        public IActionResult Service(int ticketId)
        {
            //get the ticket Object
            var ticket = context.Tickets.Find(ticketId);
            IEnumerable <Event> events = context.Events.Where(e => e.Category == EventCategory.HWService || e.Category == EventCategory.SWService).ToList();
            //create LogEditViewModel
            var model = new NewLogServiceViewModel
            {
                TicketId     = ticket.Id,
                TicketNumber = ticket.TicketNumber,
                TicketStatus = context.Logs.GetLatestLogByTicketId(ticketId).TicketStatus,
                Events       = SelectListHelper.ToSelectListItems(events, -1) // nothing selected
            };

            return(View(model));
        }