public IActionResult CreateFood([FromBody] FoodForCreationDto foodInfo) { var foodError = "Please look at your data and make sure it's not empty, incorrect, or has values that are the same!"; Food food = new Food(); if (foodInfo == null) { return(BadRequest(foodError)); } food.Name = foodInfo.Name; if (food.Name == null || food.Name.Length > 10) { return(StatusCode(500, "Sorry, the name is too long, or you forgot to enter it")); } food.Description = foodInfo.Description; if (food.Description == null || food.Name.Length > 100) { return(StatusCode(500, "Sorry, the description is too long, or you forgot to enter it")); } food.RestaurantId = foodInfo.RestaurantId; food.Cost = foodInfo.Cost; if (food.Cost == null || food.Cost.Equals(0)) { return(StatusCode(500, "Sorry, the cost cannot be 0")); } food.CreatedAtDate = DateTime.Now; food.UpdatedAtDate = food.CreatedAtDate; _foodInfoRepository.AddFood(food); if (!_foodInfoRepository.Save()) { return(StatusCode(500, "Something went wrong during the request...")); } return(Ok(food)); }