private static WebStoreItemDTO ItemToDTO(WebStoreItem webStoreItem) => new WebStoreItemDTO { Id = webStoreItem.Id, Name = webStoreItem.Name, Description = webStoreItem.Description, Price = webStoreItem.Price, IsAvailable = webStoreItem.IsAvailable, IsDiscounted = webStoreItem.IsDiscounted, Picture = webStoreItem.Picture };
public async Task <ActionResult <WebStoreItemDTO> > CreateWebStoreItem(WebStoreItemDTO webStoreItemDTO) { var webStoreItem = new WebStoreItem { Name = webStoreItemDTO.Name, Description = webStoreItemDTO.Description, Price = webStoreItemDTO.Price, IsAvailable = webStoreItemDTO.IsAvailable, IsDiscounted = webStoreItemDTO.IsDiscounted, Picture = webStoreItemDTO.Picture }; _context.WebStoreItems.Add(webStoreItem); await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(GetWebStoreItem), new { id = webStoreItem.Id }, ItemToDTO(webStoreItem))); }