public bool CheckWorkaholic() { int streak = 0; IEnumerable <Habit> hList = HabitRepository.GetHabitByUserId(_habit.UserID); foreach (Habit hb in hList) { IEnumerable <Log> logList = HabitRepository.GetLogDataByID(hb.ID, hb.UserID); Log temp = null; foreach (Log l in logList) { if (streak == 0) { temp = l; } else if ((l.Date_Log.Date - temp.Date_Log.Date).Days != 0) { continue; } foreach (string s in hb.DaysOff.value) { if (l.Date_Log.DayOfWeek.ToString().StartsWith(s)) { ++streak; if (streak >= 10) { return(true); } } } } } return(false); }
public ActionResult <IEnumerable <Habit> > All(Guid user_id) { var UserHabits = HabitRepository.GetHabitByUserId(user_id); if (UserHabits != null) { return(Ok(UserHabits)); } return(NotFound("user not found")); }