public void Close(CloseTicketCommand command)
        {
            command.Validate();

            if (AddNotifications(command))
            {
                return;
            }

            Ticket ticket = _ticketRepository.GetById(command.TicketId);

            if (NotifyNullTicket(ticket) || NotifyCantAccessTicket(ticket))
            {
                return;
            }

            ticket.Close();

            if (AddNotifications(ticket))
            {
                return;
            }

            _ticketRepository.Update(ticket);

            if (Commit())
            {
                PublishLocal(new TicketClosedEvent(ticket.Id));
            }
        }
Example #2
0
        public IActionResult Close(Guid id)
        {
            CloseTicketCommand command = new CloseTicketCommand
            {
                TicketId = id
            };

            _ticketApplicationService.Close(command);

            return(CreateResponse());
        }
        public void ShouldFailToCloseTicketAndAddNotification()
        {
            CloseTicketCommand command = new CloseTicketCommand
            {
                TicketId = new Guid("36f90131-8ab3-4764-a56c-2ee78284562f")
            };

            applicationService.Close(command);
            applicationService.Close(command);

            Assert.AreEqual("Ticket finalizado", domainNotificationHandler.GetNotifications().First().Title);
        }
        public void ShouldCloseTicket()
        {
            CloseTicketCommand command = new CloseTicketCommand
            {
                TicketId = new Guid("36f90131-8ab3-4764-a56c-2ee78284562f")
            };

            applicationService.Close(command);

            Ticket ticket = applicationService.GetById(new Guid("36f90131-8ab3-4764-a56c-2ee78284562f"));

            Assert.AreEqual(Status.Closed, ticket.TicketStatus.Status);
        }