public FoodPriceDto AddFoodPrice(FoodPriceParameter foodPriceParameter, int userId) { var newFoodPrice = new FoodPrice() { FoodId = foodPriceParameter.FoodId, Price = foodPriceParameter.Price, StartDate = foodPriceParameter.StartDate ?? DateTime.Now, CreatedBy = userId, CreatedAt = DateTime.Now }; _foodPriceRepositories.AddFoodPrice(newFoodPrice); return(FoodPriceDto.ToFoodPriceDto(newFoodPrice)); }
public FoodPriceDto UpdateFoodPrice(FoodPriceParameter foodPriceParameter, int userId) { var foodPrice = _foodPriceRepositories.GetFoodPrice(foodPriceParameter.Id); if (foodPrice != null) { foodPrice.FoodId = foodPriceParameter.FoodId; foodPrice.Price = foodPriceParameter.Price; foodPrice.StartDate = foodPriceParameter.StartDate ?? DateTime.Now; foodPrice.UpdatedBy = userId; foodPrice.UpdatedAt = DateTime.Now; return(FoodPriceDto.ToFoodPriceDto(_foodPriceRepositories.UpdateFoodPrice(foodPrice))); } return(null); }
public FoodPriceDto GetCurrentFoodPrice(int foodId) { var foodPrice = _foodPriceRepositories.GetCurrentFoodPrice(foodId); return(FoodPriceDto.ToFoodPriceDto(foodPrice)); }