public async Task <ActionResult> AssignTicket(Ticket model)
        {
            var ticket = db.Tickets.Find(model.Id);

            ticket.AssignedToUserId = model.AssignedToUserId;
            ticket.TicketStatusId   = ticketHelper.AssignedTicketStatus();

            if (ticket.AssignedToUserId == null)
            {
                ticket.AssignedToUserId = model.AssignedToUserId = null;
                ticket.TicketStatusId   = ticketHelper.SetDefaultTicketStatus();
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            else
            {
                //ticket.AssignedToUserId = model.AssignedToUserId;
                //ticket.TicketStatusId = ticketHelper.AssignedTicketStatus();
                var oldTicket = db.Tickets.AsNoTracking().FirstOrDefault(t => t.Id == ticket.Id);

                ticket.Updated         = DateTime.Now;
                db.Entry(ticket).State = EntityState.Modified;



                db.SaveChanges();


                var newTicket = db.Tickets.AsNoTracking().FirstOrDefault(t => t.Id == ticket.Id);
                tkHistory.RecordHistoricalChanges(oldTicket, newTicket);
                //decide for yourself NotificationHelper if a Notification needs to be generated
                notificationHelper.ManageNotifications(oldTicket, newTicket);


                var callbackUrl = Url.Action("Details", "Tickets", new { id = ticket.Id }, protocol: Request.Url.Scheme);

                try
                {
                    EmailService    ems  = new EmailService();
                    IdentityMessage msg  = new IdentityMessage();
                    ApplicationUser user = db.Users.Find(model.AssignedToUserId);

                    msg.Body        = $"You have been assigned a Ticket.{Environment.NewLine} Please click the following link to view the details <a href=\"{callbackUrl}\">NEW TICKET</a>";
                    msg.Destination = user.Email;
                    msg.Subject     = "You've been assigned a Ticket";

                    await ems.SendMailAsync(msg);
                }
                catch (Exception ex)
                {
                    await Task.FromResult(0);
                }

                return(RedirectToAction("Index"));
            }
        }