Exemple #1
0
        private HabitResponse ConvertFromHabitToHabitResponse(Habit habit)
        {
            HabitResponse logs = GetRequiredDataFromLogs(habit.ID);
            List <String> list = dayOffRepository.GetDayOffByHabitId(habit.ID);

            return(new HabitResponse()
            {
                ID = habit.ID,
                Name = habit.Name,
                DayOffList = list,
                CurrentStreak = logs.CurrentStreak,
                LongestStreak = logs.LongestStreak,
                LogCount = logs.LogCount,
                Logs = logs.Logs,
                UserID = habit.UserID,
                CreatedAt = habit.CreatedAt
            });
        }
        private bool isWorkaholic(Dictionary <Guid, List <DateTime> > HabitAndLogs)
        {
            int             count     = 0;
            List <DateTime> dateTimes = new List <DateTime>();

            foreach (var item in HabitAndLogs)
            {
                List <String> dayOffList = dayOffRepository.GetDayOffByHabitId(item.Key);
                foreach (DateTime date in item.Value)
                {
                    if (dayOffList.Contains(date.DayOfWeek.ToString().Substring(0, 3)) && !dateTimes.Contains(date))
                    {
                        count++;
                        dateTimes.Add(date);
                    }
                    if (count == 10)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }