public static InventoryDto MapDto(this Inventory inventory) { var item = inventory.Item; var dto = new InventoryDto { Id = inventory.Id, Item = item.MapDto(), Quantity = inventory.Quantity, UnitPrice = inventory.UnitPrice }; return(dto); }
public async Task <ActionResult <InventoryDto> > CreateAsync([FromBody] InventoryDto dto, CancellationToken cancellationToken) { var itemDto = dto.Item; var item = itemDto.MapItem(); var inventory = new Inventory { Quantity = dto.Quantity, UnitPrice = dto.UnitPrice, Item = item }; inventory = await _repo.AddAsync(inventory, cancellationToken); return(Ok(inventory)); }