public ActionResult Add(Ticket ticket) { if (ModelState.IsValid) { ticket.CompanyId = OperatingUser.CompanyId; ticket.CreatedById = OperatingUser.Id; ticket.ModifiedById = OperatingUser.Id; _ticketService.Add(ticket); var userIds = ticket.NotifyTo?.Split(',').ToList() ?? new List <string>(); userIds.Add(ticket.RequestorId); userIds.Add(ticket.AssignedToId); userIds.Add(ticket.CreatedById); List <string> contributors = _userService.GetEmailsById(userIds.ToArray()); ticket.LinkToTicketDetails = $"{Request.Url.Scheme}://{Request.Url.Host}{Url.Action("Edit", "Ticket", new {id = ticket.Id})}"; string emailMessage = _ticketService.ComposeTicketCreatedEmail(ticket); _emailService.SendEmail(emailMessage, $"New Ticket: {ticket.Title}", contributors.Distinct().ToArray()); if (ticket.Id > 0) { return(RedirectToAction("Edit", "Ticket", new { id = ticket.Id })); } } else { ReadModelStateError(ModelState); } return(View(ticket)); }