public DayViewModel([NotNull] Day dayData, WeekType weekType, int parity, [NotNull] LessonMenuItemsFactory menuItemsFactory, bool isTeacher, int holderId, NavigationFlow navigationFlow, [CanBeNull] Group group) { if (dayData == null) { throw new ArgumentNullException("dayData"); } if (menuItemsFactory == null) { throw new ArgumentNullException("menuItemsFactory"); } _dayData = dayData; _parity = parity; _isTeacher = isTeacher; _holderId = holderId; _navigationFlow = navigationFlow; _group = @group; _date = SetUpDayName(weekType); NavigationFlow = navigationFlow; if (_dayData.Lessons != null) { Lessons = new ObservableCollection <LessonViewModel>( FilterLessons(_dayData.Lessons, menuItemsFactory)); } else { Lessons = new ObservableCollection <LessonViewModel>(); } }
public static string CreateDailyMessage(string groupName, WeekType week, int day) { var repository = new ServerStorageRepository(); var localRepo = new LocalStorageRepository(); var lessonList = repository.GetLessonList(groupName, day, week); var localList = localRepo.GetLessonList(groupName, day, week); var msg = AnswerGeneratorService.GenerateHeader(week, day); if (lessonList.Except(localList).Any()) { msg += "❌ ИСУ вернула расписание, отличное от локального\n" + "С ИСУ:\n" + string.Join("\n", lessonList.Select(AnswerGeneratorService.LessonToString)) + "\nЛокально:\n" + string.Join("\n", localList.Select(AnswerGeneratorService.LessonToString)); } else if (!lessonList.Any()) { msg += AnswerGeneratorService.NoLessonMessage(); } else { msg += string.Join("\n", lessonList.Select(AnswerGeneratorService.LessonToString)); } return(msg); }
public List <LessonModel> GetLessonList(string groupName, int day, WeekType weekType) { return(ReadFromFile(groupName) .Where(l => l.DayOfWeek == day && (l.WeekType == weekType || l.WeekType == WeekType.All)) .ToList()); }
public override string ToString() { var result = Day.ToString() + " " + Time.Hour.ToString() + ":" + Time.Minute.ToString() + " " + Group.ToString() + " " + Subject.ToString() + " " + Type.ToString() + " " + WeekType.ToString() + " " + Room.ToString() + " " + Teacher.ToString(); return(result); }
public static string GenerateHeader(WeekType targetWeekType, int targetDay) { var week = targetWeekType != WeekType.Odd ? "чётная" : "нечётная"; var greeting = "🔑 Расписание на завтра!\n 👀 Нас ждёт "; greeting += $"{GetDayName(targetDay)}, {week} неделя \n"; return(greeting); }
public List <LessonModel> GetLessonList(string groupName, int day, WeekType weekType) { var lessons = GetFromApi(groupName); return(lessons .Where(l => l.DayOfWeek == day && (l.WeekType == weekType || l.WeekType == WeekType.All)) .ToList()); }
public Filter(DateFilter dateFilter, ModuleFilter moduleFilter, WeekFilter weekFilter, bool sessionFilter, WeekType firstWeekType) { this.DateFilter = dateFilter; this.ModuleFilter = moduleFilter; this.WeekFilter = weekFilter; this.SessionFilter = sessionFilter; this.FirstWeekType = firstWeekType; }
public RequisitionItem(LearningPlanItem planItem, GroupRequisition[] groupPriorities, string location, int repetitionsCount, MeetingTimeRequisition[] meetingTimePriorities, Teacher teacher, WeekType weekType) { PlanItem = planItem; GroupPriorities = groupPriorities; Location = location; RepetitionsCount = repetitionsCount; MeetingTimePriorities = meetingTimePriorities; Teacher = teacher; WeekType = weekType; }
public IEnumerable <DayViewModel> CreateList([CanBeNull] IEnumerable <Day> models, NavigationFlow navigationFlow, Group group, WeekType type, int parity) { if (models == null) { return(Enumerable.Empty <DayViewModel>()); } return(models.Select( day => new DayViewModel(day, type, parity, _menuItemsFactory, _isTeacher, _holderId, navigationFlow, group))); }
public bool NewWeek(int newWeek, WeekType newWeekType) { var current = _game.Find(record => true).SingleOrDefault(); var filter = Builders <GameDocument> .Filter.Eq(record => record.Id, current.Id); var update = Builders <GameDocument> .Update.Set(record => record.Week, newWeek) .Set(record => record.NextWeekType, newWeekType); var result = _game.UpdateOne(filter, update); return(result.ModifiedCount == 1); }
public Lesson(DateTime time, LessonType type, string group, string room, WeekType weekType, DayOfWeek day, ITeacher teacher, ISubject name) { Time = time; Type = type; Group = group; Room = room; WeekType = weekType; Day = day; Teacher = teacher; Subject = name; }
public Subject[] GetSubjects(DateTime upperWeekDate, DateTime date) { Subject[] subjects = Timetable.GetSubjects(date.DayOfWeek); if (subjects == null || subjects.Length == 0) { return(null); } WeekType currentWeekType = date.GetWeekType(upperWeekDate); subjects = subjects.Where(s => s.Week.HasFlag(currentWeekType)).ToArray(); return((subjects.Length == 0) ? null : subjects); }
public WeekViewModel(IEnumerable <Day> days, int weekNumber, [NotNull] DayViewModelFactory dayViewModelFactory, WeekType type, NavigationFlow navigationFlow, [CanBeNull] Group group) { if (dayViewModelFactory == null) { throw new ArgumentNullException("dayViewModelFactory"); } var parity = weekNumber % 2; WeekNumber = weekNumber; Days = new ObservableCollection <DayViewModel>( dayViewModelFactory.CreateList(days, navigationFlow, @group, type, parity) .Where(d => d.Lessons.Any())); }
public ClassInstance(Class classData, ClassType classType, TimeSpan from, TimeSpan to, string room, WeekDay day, WeekType weekType, Teacher teacher, string uid = "") { this.classData = classData; this.classType = classType; this.from = from; this.to = to; this.room = room; this.weekDay = day; this.weekType = weekType; this.teacher = teacher; if (string.IsNullOrWhiteSpace(uid)) this.uid = Guid.NewGuid().ToString(); else this.uid = uid; }
public ClassInstance(Class classData, ClassType classType, TimeSpan from, TimeSpan to, string room, WeekDay day, WeekType weekType, Teacher teacher, string uid = "") { this.classData = classData; this.classType = classType; this.from = from; this.to = to; this.room = room; this.weekDay = day; this.weekType = weekType; this.teacher = teacher; if (string.IsNullOrWhiteSpace(uid)) { this.uid = Guid.NewGuid().ToString(); } else { this.uid = uid; } }
private DateTime SetUpDayName(WeekType weekType) { var today = DateTime.Now; var delta = (7 + (today.DayOfWeek - DayOfWeek.Monday)) % 7; var monday = today.AddDays(-delta); switch (weekType) { case WeekType.Previous: monday -= TimeSpan.FromDays(7); break; case WeekType.Current: break; case WeekType.Next: monday += TimeSpan.FromDays(7); break; default: throw new ArgumentOutOfRangeException("weekType"); } return((monday + TimeSpan.FromDays(_dayData.Weekday - 1)).Date); }
public WeekTimetable(DateTime _weekStartDay) { weekStartDay = _weekStartDay; weekType = GetIso8601WeekNumber(weekStartDay) % 2 == 0?WeekType.Even:WeekType.Odd; days = new List <DayTimetable> (); }
public static string GetPairMD5(DayOfWeek day, string time, string name, string location, string lecturer, WeekType week_type) { return(CalculateMD5Hash((week_type == WeekType.Odd?"1":"0") + day.ToString() + time + name + location + lecturer)); }
public void MondayLessonList(int day, WeekType weekType, int count) { //TODO: fix this test //var lessons = _repository.GetLessonList(_groupName, day, weekType); //Assert.AreEqual(lessons.Count(), count); }
public static string GetOLDPairMD5(string time, string name, string location, string lecturer, WeekType week_type) { return(CalculateMD5Hash((week_type == WeekType.Odd?"1":"0") + time + name + location + lecturer)); }
public WeekViewModel Create([CanBeNull] IEnumerable <Day> days, int weekNumber, WeekType weekType, NavigationFlow navigationFlow, [CanBeNull] Group group) { return(new WeekViewModel(days, weekNumber, _dayViewModelFactory, weekType, navigationFlow, group)); }