Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        public bool PostTicket(Ticket item)
        {
            item = repositorio.Add(item);

            string uri = Url.Link("DefaultApi", new { id = item.TicketId });

            return(true);
        }
Esempio n. 3
0
        public void AddTicket()
        {
            var ticket = new Ticket
            {
                Title       = "Test Ticket",
                Description = "Test Description",
                StatusId    = 1
            };

            _ticketService.Add(ticket);
        }