public OutputDtoQueryItem Create(int categoryId, InputDtoAddItem inputDtoAddItem) { var categoryFromDto = _categoryRepository.GetById(categoryId); var itemFromDto = new Item { Label = inputDtoAddItem.Label, Price = inputDtoAddItem.Price, ImageItem = inputDtoAddItem.ImageItem, DescriptionItem = inputDtoAddItem.DescriptionItem, Category = categoryFromDto }; var itemInDb = _itemRepository.Create(categoryId, itemFromDto); return(new OutputDtoQueryItem { Id = itemInDb.Id, Label = itemInDb.Label, Price = itemInDb.Price, ImageItem = itemInDb.ImageItem, DescriptionItem = itemInDb.DescriptionItem, ItemCategory = new OutputDtoQueryItem.Category { Id = itemInDb.Category.Id, Title = itemInDb.Category.Title } }); }
public ActionResult <OutputDtoQueryItem> AddItem(int categoryId, [FromBody] InputDtoAddItem item) { return(Ok(_itemService.Create(categoryId, item))); }