예제 #1
0
        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));
        }
예제 #2
0
        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()));
        }
예제 #3
0
        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()));
        }