public void ShouldRequireMinimumFields() { var command = new CreatePhoneCommand(); FluentActions.Invoking(() => SendAsync(command)).Should().Throw <ValidationException>(); }
public async Task ShouldCreatePhone() { var userId = await RunAsDefaultUserAsync(); var contactId = await SendAsync(new CreateContactCommand { Title = "Dr", FirstName = "Bat", LastName = "Man", }); var command = new CreatePhoneCommand { ContactId = contactId, PhoneNumber = "1232344345" }; var itemId = await SendAsync(command); var item = await FindAsync <Phone>(itemId); item.Should().NotBeNull(); item.ContactId.Should().Be(command.ContactId); item.PhoneNumber.Should().Be(command.PhoneNumber); item.CreatedBy.Should().Be(userId); item.Created.Should().BeCloseTo(DateTime.Now, 10000); item.LastModifiedBy.Should().BeNull(); item.LastModified.Should().BeNull(); }
public async Task <ActionResult <CreatePhoneCommandResponse> > CreatePhone([FromBody] CreatePhoneCommand command) { var result = await commandBus.ExecuteAsync <CreatePhoneCommand, CreatePhoneCommandResponse>(command); return(CreatedAtAction("Phone", new { id = result.Id }, result)); }
public Phone Create(CreatePhoneCommand command) { var phone = new Phone(command.DDD, command.Number, command.Description); phone.Validate(); _repository.Create(phone); if (Commit()) { return(phone); } return(null); }
public async Task <ActionResult <int> > Create(CreatePhoneCommand command) { return(await Mediator.Send(command)); }