public async Task <IActionResult> AddHabitToProgress(int numOfTimes) { WebbyWeb.Models.Progress progress = GetProgress(); progress.NumOfHabits += 1; progress.WeeklyPtsPossible = progress.WeeklyPtsPossible + (7 - progress.DayTracker) * numOfTimes; progress.MonthlyPtsPossible = progress.MonthlyPtsPossible + (30 - progress.DayTracker) * numOfTimes; try { _context.Update(progress); await _context.SaveChangesAsync(); } catch (Exception exc) { throw exc; } return(RedirectToAction("StartHabits")); }
public IActionResult UpdateDayTracker(string source) { WebbyWeb.Models.Progress progress = GetProgress(); DateTime oldDate = progress.DateTracker; //old date DateTime todaysDate = DateTime.Now.Date; //todays int span = (todaysDate - oldDate).Days; int DayTracker = progress.DayTracker; if (span != DayTracker) //DateTracker off, { ResetDoneOrNotForProfile(); progress.DayTracker = span; try { _context.Update(progress); _context.SaveChanges(); } catch (Exception exc) { throw exc; } } ViewBag.DayTracker = progress.DayTracker; return(RedirectToAction(source, "Home")); }