/// <inheritdoc /> public async Task CreateAsync(FoodCreate food) { var entity = _mapper.Map <Food>(food); await _repo.CreateAsync(entity); await _repo.SaveAsync(); }
public async Task <ActionResult <FoodItemDto> > CreateAsync(CreateFoodItemDto createFoodItemDto) { var foodItem = new FoodItem { Name = createFoodItemDto.name, Description = createFoodItemDto.description, Price = createFoodItemDto.price }; await _foodRepository.CreateAsync(foodItem); // Creates a 201 response that returns the created item. return(CreatedAtAction(nameof(GetByIdAsync), new { id = foodItem.Id }, foodItem)); }