Esempio n. 1
0
        public IActionResult AttachIssuePicture(Guid id, [FromBody] AttachIssuePictureCommand command)
        {
            command.TicketId = id;

            _ticketApplicationService.AttachIssuePicture(command);

            return(CreateResponse());
        }
        public void ShouldAttachIssuePicture()
        {
            string base64 = "bHVjYXM=";

            AttachIssuePictureCommand command = new AttachIssuePictureCommand
            {
                TicketId     = new Guid("36f90131-8ab3-4764-a56c-2ee78284562f"),
                IssuePicture = base64
            };

            applicationService.AttachIssuePicture(command);

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

            Assert.IsNotNull(ticket.IssuePicture);
        }
        public void ShouldFailToAttachIssuePictureAndAddNotification()
        {
            identityResolver.RefreshId();

            string base64 = "bHVjYXM=";

            AttachIssuePictureCommand command = new AttachIssuePictureCommand
            {
                TicketId     = new Guid("36f90131-8ab3-4764-a56c-2ee78284562f"),
                IssuePicture = base64
            };

            applicationService.AttachIssuePicture(command);

            Assert.AreEqual("Erro ao anexar", domainNotificationHandler.GetNotifications().First().Title);
        }
Esempio n. 4
0
        public void AttachIssuePicture(AttachIssuePictureCommand command)
        {
            command.Validate();

            if (AddNotifications(command))
            {
                return;
            }

            Image issuePicture = new Image(command.IssuePicture.ToBytes());

            Ticket             ticket = _ticketRepository.GetById(command.TicketId);
            LedgerIdentityUser user   = _identityResolver.GetUser();

            if (NotifyNullTicket(ticket))
            {
                return;
            }

            if (ticket.TicketUserId != user.Id)
            {
                AddNotification("Erro ao anexar", "O usuário não tem permissão para anexar arquivos ao ticket.");
                return;
            }

            ticket.AttachIssuePicture(issuePicture);

            if (AddNotifications(ticket))
            {
                return;
            }

            _ticketRepository.Update(ticket);

            Commit();
        }