Ejemplo n.º 1
0
        public List <DayMeal> GetWeekDate(int Year)
        {
            DayMeal        d      = new DayMeal();
            List <DayMeal> datesW = d.GetWeekDate(Year);

            return(datesW);
        }
Ejemplo n.º 2
0
        public bool CreateMealsOfDayInAWeek(DayMeal dm)
        {
            Meal m     = new Meal();
            bool saved = m.CreateMealsOfDayInAWeek(dm);

            return(saved);
        }
Ejemplo n.º 3
0
 public static void DeleteDailyFood(DayMeal dayMeal)
 {
     try
     {
         db.Delete(dayMeal);
     }
     catch (Exception exception)
     {
     }
 }
Ejemplo n.º 4
0
 public static DayMeal DtoToDayMeal(DayMealDTO product, DayMeal ent = null)
 {
     if (product != null)
     {
         return(ent = ent ?? new DayMeal
         {
             DayMealId = product.DayMealId,
             DayId = product.DayId,
             MealId = product.MealId,
             Category = product.Category
         });
     }
     return(null);
 }
Ejemplo n.º 5
0
 public static DayMealDTO DayMealToDto(DayMeal product, DayMealDTO dto = null)
 {
     if (product != null)
     {
         return(dto = dto ?? new DayMealDTO
         {
             DayMealId = product.DayMealId,
             DayId = product.DayId,
             MealId = product.MealId,
             Category = product.Category
         });
     }
     return(null);
 }
Ejemplo n.º 6
0
        public static void AddDayMeal(Food food, decimal servingSize)
        {
            DayMeal dayMeal = new DayMeal();

            dayMeal.Id       = DatabaseManager.GetLastDayMealId() + 1;
            dayMeal.Day      = DateTime.Now.ToLocalTime();
            dayMeal.FoodId   = food.Id;
            dayMeal.FoodName = food.Name;
            dayMeal.Grams    = servingSize * food.ServingSizeGrams;
            dayMeal.Calories = food.CaloriesInServingSize(servingSize);
            dayMeal.Carbs    = food.CarbsInServingSize(servingSize);
            dayMeal.Sugar    = food.SugarsInServingSize(servingSize);
            dayMeal.Proteins = food.ProteinsInServingSize(servingSize);
            dayMeal.Fats     = food.FatsInServingSize(servingSize);
            db.Insert(dayMeal);
        }
Ejemplo n.º 7
0
        private async void OpenEditDayMealDialogAsync(DayMeal meal)
        {
            var mealClone = meal.Clone();

            var dialog = _dialogs.For <DayMealDialogViewModel>(DialogsIdentifier);

            dialog.Data.DialogTitle       = "Modified meal";
            dialog.Data.SubmitButtonTitle = "Save";
            dialog.Data.DayMeal           = DayMealViewModel.FromModel(mealClone);

            var dialogResult = await dialog.Show();

            if (dialogResult != DialogResult.Ok)
            {
                return;
            }

            mealClone = dialog.Data.DayMeal.ToModel();
            EatingDay.Meals.Replace(meal, mealClone);
        }
Ejemplo n.º 8
0
        private async void OpenAddDayMealDialogAsync()
        {
            var meal = new DayMeal
            {
                Hour = DateTime.Today.Hour
            };

            var dialog = _dialogs.For <DayMealDialogViewModel>(DialogsIdentifier);

            dialog.Data.DialogTitle       = "New meal";
            dialog.Data.SubmitButtonTitle = "Create";
            dialog.Data.DayMeal           = DayMealViewModel.FromModel(meal);

            var dialogResult = await dialog.Show();

            if (dialogResult != DialogResult.Ok)
            {
                return;
            }

            meal = dialog.Data.DayMeal.ToModel();
            EatingDay.Meals.Add(meal);
            EatingDay.Meals.Refresh(meal);
        }
Ejemplo n.º 9
0
 private void RemoveMeal(DayMeal meal) => EatingDay.Meals.RemoveByReference(meal);