public async Task <IActionResult> Put([FromBody] UpsertMemberRequest request) { var result = await mediator.Send(request); var entity = result.Entity; if (result.Added) { return(CreatedAtAction("Get", new { id = entity.Id }, entity)); } return(Ok()); }
public async Task when_inserted_added_equals_true() { // prepare var sut = GetSut(); var request = new UpsertMemberRequest { Id = Guid.NewGuid().ToString(), Entity = new Member { FirstName = "John", LastName = "Smith" } }; // execute var response = await sut.Handle(request, new CancellationToken()); // verify response.Added.Should().BeTrue(); }
public async Task when_updated_added_equals_false() { // prepare var items = await GetDbContext().GetAll <Member>(); var firstItem = items.FirstOrDefault(); var sut = GetSut(); var request = new UpsertMemberRequest { Id = firstItem.UniqueId, Entity = new Member { FirstName = "John", LastName = "Smith" } }; // execute var response = await sut.Handle(request, new CancellationToken()); // verify response.Added.Should().BeFalse(); }