コード例 #1
0
        public static (int Day, DataWeekType Week) GetDayAndWeek(DateTime data)
        {
            DataWeekType todayWeek = GetWeekType(data);
            var          todayDay  = (int)data.DayOfWeek;

            todayDay = (todayDay + 6) % 7;
            return(todayDay, todayWeek);
        }
コード例 #2
0
        public static string MakeString(this DataWeekType week)
        {
            switch (week)
            {
            case DataWeekType.Even:
                return("чётная");

            case DataWeekType.Odd:
                return("нечётная");

            default:
                throw new ArgumentOutOfRangeException(nameof(week), week, null);
            }
        }
コード例 #3
0
        public static string CreateDailyMessage(string groupName, DataWeekType week, int day)
        {
            //List<ScheduleItemModel> localSchedule = LocalStorageRepository.GetLessonList(groupName, day, week);
            var    isuSchedule = ServerApiRepository.GetLessonList(groupName, (DataDayType)day, week);
            string header      = AnswerGeneratorService.GenerateHeader(week, day);

            return(header);
            //TODO: fix
            //return header += string.Join("\n", isuSchedule.Select(AnswerGeneratorService.LessonToString));

            //TODO: fix this

/*
 *          if (isuSchedule == null)
 *          {
 *              //TODO: isu empty
 *              if (localSchedule == null)
 *              {
 *                  //TODO: isu and local empty
 *              }
 *          }
 *          else
 *          {
 *              if (localSchedule == null)
 *              {
 *                  //TODO: no local data
 *              }
 *              else
 *              {
 *                  if (isuSchedule.Except(localSchedule).Any())
 *                  {
 *                      return header + AnswerGeneratorService.DifferentSchedule(isuSchedule, localSchedule);
 *                  }
 *
 *                  if (!isuSchedule.Any())
 *                  {
 *                      return header += AnswerGeneratorService.NoLessonMessage();
 *                  }
 *
 *                  return header += string.Join("\n", isuSchedule.Select(AnswerGeneratorService.LessonToString));
 *              }
 *          }
 *
 *          return header;
 */
        }
コード例 #4
0
        public void MondayLessonList(int day, DataWeekType weekType, int count)
        {
            var lessons = ServerApiRepository.GetLessonList(GroupName, (DataDayType)day, weekType);

            Assert.AreEqual(lessons.Count, count);
        }
コード例 #5
0
 public static string GenerateHeader(DataWeekType targetWeekType, int targetDay)
 {
     return("🔑 Расписание на завтра!\n 👀 Нас ждёт "
            + $"{GetDayName(targetDay)}, {targetWeekType.MakeString()} неделя \n");
 }
コード例 #6
0
        public static List <ScheduleItemModel> GetLessonList(string groupName, DataDayType day, DataWeekType weekType)
        {
            List <ScheduleItemModel> lessons = GetLessonList(groupName);

            return(lessons
                   ?.Where(l => l.DataWeek.Compare(weekType) && l.DataDay == day)
                   .ToList());
        }