public void Register(RegisterTicketCommand command)
        {
            command.Validate();

            if (AddNotifications(command))
            {
                return;
            }

            TicketCategory     category = _categoryRepository.GetById(command.CategoryId);
            LedgerIdentityUser user     = _identityResolver.GetUser();

            if (NotifyNullCategory(category))
            {
                return;
            }

            Ticket ticket = _factory.OpenTicket(command.Title, command.Details, command.CategoryId, user.Id);

            _ticketRepository.Register(ticket);

            if (Commit())
            {
                PublishLocal(new TicketRegisteredEvent(ticket.Id, ticket.Title, ticket.Details));
            }
        }
        public void ShouldRegisterTicket()
        {
            Guid categoryId = new Guid("3fe0fcc8-b00d-40ec-ac18-cbeb769ff216");

            fakeTicketCategoryRepository.Register(new TicketCategory(categoryId, "Problemas"));

            RegisterTicketCommand command = new RegisterTicketCommand
            {
                CategoryId = categoryId,
                Title      = "Olá, mundo!",
                Details    = "Isso funciona"
            };

            applicationService.Register(command);

            Assert.AreEqual(2, applicationService.GetAllTickets().Count());
        }
示例#3
0
        public IActionResult Register([FromBody] RegisterTicketCommand command)
        {
            _ticketApplicationService.Register(command);

            return(CreateResponse());
        }