void UpdateOverlay() { bool alertOn = false; try { if (!IsPaused) { foreach (ServiceViewModel svm in asvm.AllItems) { if (svm.IsOnAlert) { alertOn = true; break; } } if (!alertOn) { foreach (TaskViewModel tvm in atvm.AllItems) { if (tvm.IsOnAlert) { alertOn = true; break; } } } } } catch { alertOn = false; } DashboardFunctions.OverlayAlert(mainWindow, alertOn, IsPaused); }
public void UpdatePreferencesTest() { //The unit being tested updates the Allergies list as per User DashboardFunctions TestUser = new DashboardFunctions("Testing0"); Assert.True(TestUser.UpdatePreferences("Chicken")); }
public void PreferenceTest() { //The unit being tested retrives the list of preferences that user has selected prior to loading the dashboard //User Testing0 hasnt recorded any preferences DashboardFunctions TestUser = new DashboardFunctions("Testing0"); Assert.Equal(null, TestUser.GetPreferencesList()); }
public void AllergiesTest() { //The unit being tested retrives the list of allergies that user has selected prior to loading the dashboard //User Testing0 recorded "NUTS and SOY" as allegies DashboardFunctions TestUser = new DashboardFunctions("Testing0"); Assert.Equal("NUTS,SOY", TestUser.GetAllergiesList()); }
public AllServicesViewModel() { DisplayName = "All Services"; serviceRepository = new RepositoryBase <ModelService>(Path.Combine(DashboardFunctions.GetFolder(""), "service_data.xml")); serviceRepository.ItemAdded += new Action <ModelService>(serviceRepository_ItemAdded); serviceRepository.Load(); this.RequestDelete += new EventHandler(AllServicesViewModel_RequestDelete); this.RequestAdd += new EventHandler(AllServicesViewModel_RequestAdd); DispatcherTimer.Start(); }
public AllTasksViewModel() { DisplayName = "All Tasks"; taskRepository = new RepositoryBase <ModelTask>(Path.Combine(DashboardFunctions.GetFolder(""), "task_data.xml")); taskRepository.ItemAdded += new Action <ModelTask>(taskRepository_ItemAdded); taskRepository.Load(); this.RequestDelete += new EventHandler(AllTasksViewModel_RequestDelete); this.RequestAdd += new EventHandler(AllTasksViewModel_RequestAdd); DispatcherTimer.Interval = new TimeSpan(0, 5, 0); DispatcherTimer.Start(); }
protected virtual void OnSave() { try { DashboardFunctions.SerializeToFile(Items, DataFile); } catch (Exception ex) { throw new Exception("There was a problem saving the data file." + ex.Message); } }
public void UpdatePreferences(string Preferences) { string username = HttpContext.Session.GetString("Username"); DashboardFunctions UpdateUser = new DashboardFunctions(username); if (UpdateUser.UpdatePreferences(Preferences) == false) { string action = this.ControllerContext.RouteData.Values["action"].ToString(); string controller = this.ControllerContext.RouteData.Values["controller"].ToString(); RedirectToAction("Error", new { controllerName = controller, actionName = action }); } }
public void TimeToUpdateWeightTest() { //Testing the function which checks whether 30 days have passed since last update //User Testing0 last update exceeds 30 days DashboardFunctions TestUser = new DashboardFunctions("Testing0"); //Getting Today's Date DateTime dt = DateTime.Now; //latest Month since update var TrackerList = db.ProgressTracker.ToList(); var latestMonth = TrackerList.Where(z => z.UserName.ToLower() == "testing0").Max(x => x.Month); Assert.True(TestUser.TimeOverdue(dt, latestMonth)); }
protected virtual void OnLoad() { if (File.Exists(DataFile)) { try { Items = DashboardFunctions.DeserializeFromFile <List <T> >(DataFile); foreach (T item in Items) { OnItemAdded(item); } } catch (Exception ex) { throw new Exception("There was a problem loading the data file." + ex.Message); } } else { Items = new List <T>(); } }
public IActionResult Dashboard() { try { string username = null; if (HttpContext.Session.GetString("LoggedIn") != null) { username = HttpContext.Session.GetString("Username"); } else { return(RedirectToAction("Index")); } DashboardFunctions loadUser = new DashboardFunctions(username); UserClass thisUser = new UserClass(username); ViewBag.TodayAct = loadUser.GetDailyActivityList(); var TrackerList = db.ProgressTracker.ToList(); var exerciseList = db.ExercisesListTable.ToList(); var existFood = db.FoodData.OrderBy(z => z.Id).ToList(); DateTime dt = DateTime.Now; var latestMonth = TrackerList.Where(z => z.UserName.ToLower() == username.ToLower()).Max(x => x.Month); //latest week since update //get Current date in the format specified ViewBag.date = dt.ToString("MMMM dd, yyyy", CultureInfo.CreateSpecificCulture("en-US")); ViewBag.TimeExceeded = loadUser.TimeOverdue(dt, latestMonth); var RecordedWeeks = TrackerList.Where(z => z.UserName.ToLower() == username.ToLower()).Count(); string[] weeks = new string[RecordedWeeks]; for (int i = 0; i < RecordedWeeks; i++) { weeks[i] = "Month " + (i + 1); } var WeeklyBMI = TrackerList.Where(z => z.UserName.ToLower() == username.ToLower()).OrderBy(k => k.Month).Select(x => x.Bmi).ToArray(); var exercisesArray = exerciseList.OrderBy(f => f.ExerciseList).Select(s => s.ExerciseList.Substring(0, s.ExerciseList.Length - 1)).ToArray(); var exercisesIDArray = exerciseList.OrderBy(f => f.ExerciseList).Select(s => s.ExerciseId).ToArray(); var FoodsDBArray = existFood.Select(z => z.Food).ToArray(); var FoodsIDArray = existFood.Select(z => z.Id).ToArray(); var proteins = existFood.Select(z => Math.Round((double)z.Protein, 2)).ToArray(); var Cal = existFood.Select(z => Math.Round((double)z.Calorie, 2)).ToArray(); var Carb = existFood.Select(z => Math.Round((double)z.Carbs, 2)).ToArray(); var Fat = existFood.Select(z => Math.Round((double)z.Fat, 2)).ToArray(); string [] macroString = new string[Cal.Length]; for (int k = 0; k < Cal.Length; k++) { macroString[k] = " |Calorie:" + Cal[k] + " |Protein:" + proteins[k] + " |Carb:" + Carb[k] + " |Fats:" + Fat[k] + "|"; } ViewBag.MacroString = macroString; var WeeklyW2H = TrackerList.Where(z => z.UserName.ToLower() == username.ToLower()).OrderBy(k => k.Month).Select(x => x.Wc).ToArray(); ViewBag.BMI = Math.Round(TrackerList.Where(z => z.UserName.ToLower() == username.ToLower() && z.Month == latestMonth).Select(x => x.Bmi).FirstOrDefault(), 2); ViewBag.Weight = TrackerList.Where(z => z.UserName.ToLower() == username.ToLower() && z.Month == latestMonth).Select(x => x.MonthlyWeight).FirstOrDefault(); var newValues = exercisesArray.Select(x => x.Substring(0, x.Length - 1)).ToArray(); ViewBag.Consumption = thisUser.CalConsumption(); ViewBag.ExerciseIDArr = exercisesIDArray; ViewBag.ExerciseArr = exercisesArray; ViewBag.FoodsArr = FoodsDBArray; ViewBag.FoodsIDArr = FoodsIDArray; ViewBag.WeeklyW2Hs = WeeklyW2H; ViewBag.WeeklyBMIs = WeeklyBMI; ViewBag.weeks = weeks; ViewBag.username = username; var dietuser = db.DietUsers.Find(username); ViewBag.NewUser = dietuser.NewUser; //display model if its a new user ViewBag.Macros = db.UserMacros.Where(z => z.Username.ToLower() == username.ToLower()).FirstOrDefault(); ViewBag.ChoosenAllegies = loadUser.GetAllergiesList(); ViewBag.ChoosenPreferences = loadUser.GetPreferencesList(); return(View()); } catch (SqlException) { string action = this.ControllerContext.RouteData.Values["action"].ToString(); string controller = this.ControllerContext.RouteData.Values["controller"].ToString(); return(RedirectToAction("Error", new { controllerName = controller, actionName = action })); } }
protected void Page_Load(object sender, EventArgs e) { DashboardFunctions.loadDashboard_Data(requestsInProgressLabel, balanceLabel, nextDueDateLabel); }