public IActionResult CreateFood([FromBody] FoodDto foodDto) { CreateFoodResponse response = _foodService.CreateFood(foodDto); if (!response.ResponseStatus.HasError()) { return(Ok()); } return(StatusCode(response.ResponseStatus.Status, response.ResponseStatus.Message)); }
public CreateFoodResponse CreateFood(FoodDto foodDto) { CreateFoodResponse response = new CreateFoodResponse(); try { _foodRepository.CreateFood(foodDto); response.ResponseStatus.SetOk(); } catch (Exception e) { _logger.LogError(e.ToString()); response.ResponseStatus.SetError(ResponseStatusCode.INTERNAL_SERVER_ERROR, e.ToString()); } return(response); }