Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        public FoodPriceDto GetCurrentFoodPrice(int foodId)
        {
            var foodPrice = _foodPriceRepositories.GetCurrentFoodPrice(foodId);

            return(FoodPriceDto.ToFoodPriceDto(foodPrice));
        }