public async Task <IActionResult> Put([FromForm] BookUpdateCommand request) { var stream = Request.Form.Files.Count > 0 ? Request.Form.Files["CoverImage"].OpenReadStream() : new MemoryStream(); request.SetCoverImage(stream); var result = await Mediator.Send(request); return(FromCQRS(result)); }
public BookUpdateCommandHandlerTests() { _fixture = new Fixture(); _fixture.Behaviors.Add(new OmitOnRecursionBehavior()); _context = InitializeDatabase(); _testCommand = CreateTestCommand( Guid.NewGuid(), CompletionStatusReference.Completed, false, false, 1, Guid.NewGuid()); var checkout = _fixture .Build <CheckoutRecord>() .With(c => c.ModifiedOn, DateTimeOffset.UtcNow) .Create(); var itemStorage = _fixture .Build <ItemStorageRecord>() .With(a => a.ModifiedOn, DateTimeOffset.UtcNow) .Create(); _testBook = _fixture .Build <BookRecord>() .With(a => a.Id, _testCommand.BookId) .With(a => a.Author, _testCommand.Author) .With(a => a.Checkout, checkout) .With(a => a.UpdatedOn, DateTimeOffset.UtcNow) .With(a => a.ItemStorage, itemStorage) .With(a => a.Type, _testCommand.Type) .With(a => a.TimesCompleted, 1) .With(a => a.Title, _testCommand.Title) .With(a => a.User, _testCommand.User) .With(a => a.UserId, _testCommand.User.Id) .Create(); _handler = new BookUpdateCommandHandler(_context); }