Esempio n. 1
0
        public async Task <IActionResult> DayDetails(DateTime startDate, DateTime mealDate)
        {
            Customer customer = await repository.GetCustomer(userManager, HttpContext);

            ViewData["customerName"] = customer.Name;

            OrderedMeal OrderedMealForDate = repository
                                             .GetOrderedMealForDate(startDate, mealDate, customer.EMail);

            bool test = OrderedMealForDate == null;

            System.Diagnostics.Debug.WriteLine("Ordered meal is null? " + test);

            MealDetailViewModel mealDetailViewModel =
                new MealDetailViewModel(OrderedMealForDate)
            {
                Date      = mealDate,
                StartDate = startDate
            };

            if (OrderedMealForDate != null)
            {
                int MealId = OrderedMealForDate.MealId;
                mealDetailViewModel.OrderedMeal = await repository.GetMealById(MealId);
            }

            return(View(mealDetailViewModel));
        }
        public ActionResult ModifyMeal(int mealId)
        {
            MealDetailViewModel mealDetail = new MealDetailViewModel();

            mealDetail.Recipes    = _dal.GetRecipesByMealId(mealId);
            mealDetail.Meal       = _dal.GetMealByMealId(mealId);
            mealDetail.AllRecipes = _dal.GetAllRecipesByUserId((int)Session[UserKey]);

            return(View("ModifyMeal", mealDetail));
        }
        public MealDetailPage()
        {
            InitializeComponent();

            var Meal = new Recipe
            {
                Name        = "Meal 1",
                Description = "This is an Meal description."
            };

            viewModel      = new MealDetailViewModel(Meal);
            BindingContext = viewModel;
        }
Esempio n. 4
0
        public async Task <IActionResult> Detail(int id)
        {
            var DetailViewModel = new MealDetailViewModel {
                OneDayFoodId = id
            };
            var oneDayFood = await _oneDayFoodRepository.GetOneDayFoodBiIdAsync(id);

            DetailViewModel.OneDayFoodViewModel = new OneDayFoodViewModel
            {
                AppUserID = oneDayFood.AppUserID,
                Date      = oneDayFood.Date,
                Water     = oneDayFood.Water
            };
            var collIngestions = new List <IngestionViewModel>();

            foreach (var ingestion in oneDayFood.Ingestions)
            {
                var coll = new List <WeightOfFoodViewModel>();
                foreach (var weightOfFood in ingestion.WeightOfFood)
                {
                    coll.Add(new WeightOfFoodViewModel {
                        Food = weightOfFood.Food, IngestionId = weightOfFood.IngestionID, Weight = weightOfFood.Weight
                    });
                }
                if (coll.Count == 0)
                {
                    coll.Add(new WeightOfFoodViewModel {
                        IngestionId = ingestion.IngestionID
                    });
                }
                collIngestions.Add(new IngestionViewModel
                {
                    Name         = ingestion.Name,
                    OneDayFoodId = ingestion.OneDayFoodID,
                    WeightOfFood = coll,
                });
            }
            DetailViewModel.OneDayFoodViewModel.Ingestions = collIngestions;
            DetailViewModel.CountMealPerIngestions         = new List <CountMealPerIngestion>();
            foreach (var ingestionViewModel in collIngestions)
            {
                DetailViewModel.CountMealPerIngestions.Add(ingestionViewModel.GetCountMealPerIngestion);
            }


            return(View(DetailViewModel));
        }
        public ActionResult GetMeal(int mealId)
        {
            MealDetailViewModel mealDetail = new MealDetailViewModel();

            if (IsAuthenticated)
            {
                _nextView          = "MealDetail";
                mealDetail.Meal    = _dal.GetMealByMealId(mealId);
                mealDetail.Recipes = _dal.GetRecipesByMealId(mealId);
                foreach (Recipe recipe in mealDetail.Recipes)
                {
                    recipe.FoodImageBase64 = _dal.GetImageByRecipeId(recipe.Id);
                }
            }

            return(GetAuthenticatedView(_nextView, mealDetail));
        }
        public ActionResult ModifyMeal(int id, List <int> recipeIds)
        {
            MealDetailViewModel mealDetail = new MealDetailViewModel();
            List <Recipe>       recipes    = _dal.GetRecipesByMealId(id);

            _dal.DeletaAllRecipesFromMeal(id);

            foreach (int item in recipeIds)
            {
                if (item != 0)
                {
                    _dal.AssignRecipeToMeal(id, item);
                }
            }

            mealDetail.Recipes = _dal.GetRecipesByMealId(id);
            mealDetail.Meal    = _dal.GetMealByMealId(id);

            return(RedirectToAction("GetMeal", new { mealId = id }));
        }
        public MealDetailPage(MealDetailViewModel viewModel)
        {
            InitializeComponent();

            BindingContext = this.viewModel = viewModel;
        }
Esempio n. 8
0
 public MealDetail(Meal item = null)
 {
     InitializeComponent();
     BindingContext = new MealDetailViewModel(item);
 }
Esempio n. 9
0
 public MealDetail()
 {
     BindingContext = new MealDetailViewModel();
 }
 public void Setup()
 {
     _navigationServiceMock = new Mock <INavigationService>();
     _mealDataService       = new Mock <IMealDataService>();
     _sut = new MealDetailViewModel(_navigationServiceMock.Object, _mealDataService.Object);
 }