Beispiel #1
0
        public MealBTO AddMeal(MealBTO mealBto)
        {
            MealDTO meal = new MealDTO();

            if (mealBto != null)
            {
                meal = mealRepository.Create(mealBto.BTOToMealDomain().MealDomainToDTO());
                return(meal.DTOToMealDomain().MealDomainToBTO());
            }
            return(null);
        }
Beispiel #2
0
        public MealBTO UpdateMeal(MealBTO mealBto)
        {
            MealDTO meal = new MealDTO();

            if (mealBto != null)
            {
                meal = mealRepository.Update(mealBto.BTOToMealDomain().MealDomainToDTO());
                return(meal?.DTOToMealDomain().MealDomainToBTO() ?? null);
            }
            return(null);
        }
Beispiel #3
0
        public void AddMealToBasket(MealBTO mealBTO, int quantity)
        {
            ShoppingMealDomain shoppingMeal = shoppingMeals
                                              .Where(x => x.Meal.Id == mealBTO.Id)
                                              .FirstOrDefault();

            if (shoppingMeal == null)
            {
                shoppingMeals.Add(new ShoppingMealDomain
                {
                    Meal     = mealBTO.BTOToMealDomain(),
                    MealId   = mealBTO.Id,
                    Quantity = quantity
                });
            }
            else
            {
                shoppingMeal.Quantity += quantity;
            }
        }