public async Task <ActionResult <Item> > CreateItemAsync(CreateItemDto itemDto) { var item = itemDto.AsItem(); await repository.CreateItemAsync(item); return(CreatedAtAction(nameof(GetItemAsync), new { id = item.Id }, item)); }
public async Task <ActionResult <ItemDto> > CreateItemAsync(CreateItemDto itemDto) { Item item = new(){ Id = Guid.NewGuid(), Name = itemDto.Name, Price = itemDto.Price, CreatedDate = DateTimeOffset.UtcNow }; await repository.CreateItemAsync(item); return(CreatedAtAction(nameof(GetItemAsync), new { id = item.Id }, item.AsDTO())); }
public async Task <ActionResult <ItemDto> > CreateItemAsync(CreateItemDto itemDto) { Item item = new() { Id = Guid.NewGuid(), Name = itemDto.Name, Price = itemDto.Price, CreateDate = DateTimeOffset.UtcNow }; await _repository.CreateItemAsync(item); // ReSharper disable once Mvc.ActionNotResolved return(CreatedAtAction(nameof(GetItemAsync), new { id = item.Id }, item.AsDto())); }