Beispiel #1
0
 private void GetNutrientsGoal()
 {
     BE.DailyGoalPerWeek d = currentModel.GetDailyGoalForWeek(CurrentUser, date);
     if (d != null)
     {
         this.GoalCalories = d.Calories;
         this.GoalFats     = d.Fats;
         this.GoalFibers   = d.Fibers;
         this.GoalProteins = d.Proteins;
         this.GoalSugars   = d.Sugars;
     }
     else
     {
         this.GoalCalories = "0";
         this.GoalFats     = "0";
         this.GoalFibers   = "0";
         this.GoalProteins = "0";
         this.GoalSugars   = "0";
     }
 }
Beispiel #2
0
 /// <summary>
 /// This function add to an User a daily goals for specific week
 /// </summary>
 /// <param name="dailyGoalsPerWeek"></param>
 /// <param name="currentUser"></param>
 public void AddDailyGoalsPerWeek(BE.DailyGoalPerWeek dailyGoalsPerWeek, User currentUser)
 {
     using (FoodBackDBEntities FBContext = new FoodBackDBEntities())
     {
         var user = FBContext.Users.Single(u => u.EmailAddress.Equals(currentUser.EmailAddress));
         DailyGoalPerWeek dailyInThisWeek = null;
         foreach (DailyGoalPerWeek d in user.DailyGoalPerWeeks)
         {
             if (d.SundayOfWeek == dailyGoalsPerWeek.SundayOfWeek)
             {
                 dailyInThisWeek = d;
                 break;
             }
         }
         if (dailyInThisWeek != null)
         {
             user.DailyGoalPerWeeks.Remove(dailyInThisWeek);
         }
         user.DailyGoalPerWeeks.Add(dailyGoalsPerWeek);
         dailyGoalsPerWeek.Users.Add(user);
         FBContext.SaveChanges();
     }
 }
Beispiel #3
0
 public void UpdateGoalData(DateTime aSundayOfWeek, string aCalories, string aFats, string aCarbs, string aProteins, string aSugar, string[,] aFullGoals, User u)
 {
     dailyGoal = new BE.DailyGoalPerWeek(aSundayOfWeek, aCalories, aFats, aCarbs, aProteins, aSugar, aFullGoals);
     MessageBox.Show("Good Luck", "System Message", MessageBoxButton.OK, MessageBoxImage.Information);
     bl.AddDailyGoalsPerWeek(dailyGoal, u);
 }