public FoodDto AddFood(FoodParameter foodParameter, int userId) { var newFood = new Food() { FoodName = foodParameter.FoodName, Remark = foodParameter.Remark, CreatedBy = userId, CreatedAt = DateTime.Now }; _foodRepositories.AddFood(newFood); return(FoodDto.ToFoodDto(newFood)); }
public FoodDto UpdateFood(FoodParameter foodParameter, int userId) { var food = _foodRepositories.GetFood(foodParameter.Id); if (food != null) { food.FoodName = foodParameter.FoodName; food.Remark = foodParameter.Remark; food.UpdatedBy = userId; food.UpdatedAt = DateTime.Now; return(FoodDto.ToFoodDto(_foodRepositories.UpdateFood(food))); } return(null); }
public FoodDto GetFood(int Id) { var food = _foodRepositories.GetFood(Id); return(FoodDto.ToFoodDto(food)); }