/// <summary> /// Konstruktor /// </summary> /// <param name="nav"></param> /// <param name="events"></param> /// <param name="sync"></param> public BettrFitDataSource() { _sync = new SyncDataViewModel(); Server = "https://www.bettrfit.com"; UserData = new UserVM(); UserGoals = new ObservableCollection<UserGoalVM>(); Auth = new WebAccess.ServiceReference.AuthData(); UserDaily = new ObservableCollection<UserDailyVM>(); NutritionPlanFavorites = new ObservableCollection<NutritionPlanFavoriteVM>(); NutritionPlanLeb = new ObservableCollection<LebensmittelVM>(); SummaryConsumedDaytime = new WebAccess.ServiceReference.SummaryData(); SummaryConsumedDay = new WebAccess.ServiceReference.SummaryData(); _messenger = Mvx.Resolve<IMvxMessenger>(); _mapper = new InitMapper(); _messenger.Subscribe<NetworkEvent>(m => IsNetworkAvailable = m.IsAvailable); LoadAll(); CheckLogin(); //if (ret == 0) //{ // _EventAggregator = Container.Resolve<IEventAggregator>(); // _EventAggregator.GetEvent<LoggedInEvent>().Publish(true); // _ds._loggedIn = true; //} }
public void CalcBMR(UserVM user, ref double bmr, ref double act, ref double weight, ref string answerstring) { var daily = UserDaily.OrderByDescending(a => a.Date).FirstOrDefault(); weight = (float)daily.Weight; var height = (float)user.Height; var age = Math.Round((DateTime.Now - user.Birthday).TotalDays / 365); var goal = UserGoals.FirstOrDefault(); var days = goal.WorkoutDays; var isMale = user.Gender == "M" ? true : false; if (isMale == true) { bmr = 66 + (13.7 * weight) + (5 * height) - (6.8 * age); } else { bmr = 655 + (9.6 * weight) + (1.8 * height) - (4.7 * age); } string intens = ""; if (days < 1) { act = bmr * 1.2; intens = "geringer"; } else if (days < 3) { act = bmr * 1.375; intens = "mittlerer"; } else if (days < 5) { act = bmr * 1.55; intens = "hoher"; } else if (days < 7) { act = bmr * 1.725; intens = "sehr hoher"; } answerstring = "Du bist " + age + " Jahre alt, wiegst " + Math.Round(weight) + "kg und bist " + Math.Round(height) + "cm groß. Du bewegst dich den Tag über mit " + intens + " Intensität."; act = Math.Round(act, 0); bmr = Math.Round(bmr, 0); return; }