public async Task ShouldUpdateDelivery() { var userId = await RunAsDefaultUserAsync(); var listId = await SendAsync(new CreateZoneCommand { Title = "New Zone" }); var itemId = await SendAsync(new CreateDeliveryCommand { ZoneId = listId, Title = "New Delivery" }); var command = new UpdateDeliveryCommand { Id = itemId, Title = "Updated Delivery Title" }; await SendAsync(command); var item = await FindAsync <Delivery>(itemId); item.Title.Should().Be(command.Title); item.LastModifiedBy.Should().NotBeNull(); item.LastModifiedBy.Should().Be(userId); item.LastModified.Should().NotBeNull(); item.LastModified.Should().BeCloseTo(DateTime.Now, 1000); }
public void ShouldRequireValidDeliveryId() { var command = new UpdateDeliveryCommand { Id = 99, Title = "New Delivery" }; FluentActions.Invoking(() => SendAsync(command)).Should().Throw <NotFoundException>(); }
public async Task <IActionResult> UpdateDeliveryAsync([FromBody] DeliveryDTO deliveryDTO) { var query = new UpdateDeliveryCommand(deliveryDTO); var result = await _meadiator.Send(query); return(result == true ? (IActionResult)Ok(result) : BadRequest(result)); //var delivery = _mapper.Map<Delivery>(deliveryDTO); //var res = await _deliveryService.UpdateDeliveryAysnc(delivery); //return res == true ? (IActionResult) Ok(res) : BadRequest(res); }
public async Task <ActionResult> Update(int id, UpdateDeliveryCommand command) { if (id != command.Id) { return(BadRequest()); } await Mediator.Send(command); return(NoContent()); }