Ejemplo n.º 1
0
        public ICommandResult Handle(UpdateBookCommnad command)
        {
            var book = _bookRepository.GetBook(command.Id);

            if (book == null)
            {
                AddNotification("Book", "Livro não encontrado");
                return(null);
            }

            var title             = new Name(command.Title);
            var publishingCompany = new Name(command.PublishingCompany);
            var author            = new Name(command.Author);

            book.NewValues(title, publishingCompany, author, command.Page, command.Value, command.QuantityOnHand);
            AddNotifications(book.Notifications);

            if (IsValid())
            {
                _bookRepository.Update(book);
            }

            return(new BookResult()
            {
                Id = book.Id,
                Title = book.Title.ToString()
            });
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Put([FromBody] UpdateBookCommnad command)
        {
            var result = _handler.Handle(command);

            return(await Response(result, _handler.Notifications));
        }