示例#1
0
 public List <Meal> getListOfMeal(DateTime currentDate, String emailAddress, MEALTIME mealTime)
 {
     using (var db = new FoodContext())
     {
         return((from b in db.Meals
                 where b.CurrentDate.Day == currentDate.Day && b.CurrentDate.Month == currentDate.Month &&
                 b.CurrentDate.Year == currentDate.Year && b.EmailAddress.Equals(emailAddress) && b.MealTime == mealTime
                 select b).ToList());
     }
 }
示例#2
0
        public List <FoodItem> getDailyFoodMealList(DateTime currentDate, String emailAddress, MEALTIME mealTime)
        {
            List <FoodItem> result = new List <FoodItem>();

            foreach (var item in  myDal.getListOfMeal(currentDate, emailAddress, mealTime))
            {
                result.Add(new FoodItem()
                {
                    Key = item.FoodKey, Name = item.FoodName, AmountGm = item.FoodAmount, Calories100G = item.Calories100Gm
                });
            }
            return(result);
        }
示例#3
0
        ObservableCollection <AddFoodItemViewModel> convertFoodItemListToObs(List <FoodItem> lst, MEALTIME mt)
        {
            ObservableCollection <AddFoodItemViewModel> result = new ObservableCollection <AddFoodItemViewModel>();
            AddFoodItemViewModel foodItemVm;

            foreach (var item in lst)
            {
                foodItemVm = new AddFoodItemViewModel()
                {
                    FoodNameProperty = item.Name, FoodKey = item.Key, FoodAmountProperty = item.AmountGm.ToString(), Calories100Gm = item.Calories100G, CaloriesProperty = (item.Calories100G * item.AmountGm).ToString(), GMProperty = (100 * item.AmountGm).ToString() + "g"
                };
                switch (mt)
                {
                case MEALTIME.BREAKFAST: foodItemVm.PropertyChanged += PropertyChangedFoodItemBreakfast;
                    break;

                case MEALTIME.BRUNCH:
                    foodItemVm.PropertyChanged += PropertyChangedFoodItemBrunch;
                    break;

                case MEALTIME.DINNER:
                    foodItemVm.PropertyChanged += PropertyChangedFoodItemDinner;
                    break;

                case MEALTIME.SNACKS:
                    foodItemVm.PropertyChanged += PropertyChangedFoodItemSnacks;
                    break;
                }

                result.Add(foodItemVm);
            }
            return(result);
        }
示例#4
0
 public List <FoodItem> getMealsList(string emailAddressProperty, DateTime selectedDate, MEALTIME mealTime)
 {
     return(bl.getDailyFoodMealList(selectedDate, emailAddressProperty, mealTime));
 }