Beispiel #1
0
        /// <summary>
        /// Обновление занятии
        /// </summary>
        /// <param name="children"></param>
        void UpdateLessons(Children children = null)
        {
            // Вычисление дат начала и конца недели
            var StartWeek = SelectedDate.AddDays(1 - (int)SelectedDate.DayOfWeek);
            var EndWeek   = SelectedDate.AddDays(6 - (int)SelectedDate.DayOfWeek);

            if (children == null)
            {
                Lessons = new ObservableCollection <Lesson>(Db.Lessons.Include(x => x.Room)
                                                            .Where(x => StartWeek >= x.DateStart && StartWeek <= x.DateEnd &&
                                                                   EndWeek >= x.DateStart));
                if (SelectedGroup.Name != "Все")
                {
                    Lessons = new ObservableCollection <Lesson>(Lessons.Where(x => x.Group == SelectedGroup));
                }
                if (SelectedEmployee?.Person.Lastname != "Все")
                {
                    Lessons = new ObservableCollection <Lesson>(Lessons.Where(x => x.Employee == SelectedEmployee).ToList());
                }
            }
            else
            {
                Lessons = new ObservableCollection <Lesson>(Db.Lessons.Include(x => x.Room)
                                                            .Where(x => (x.DateStart.DayOfYear >= StartWeek.DayOfYear && x.DateEnd.DayOfYear >= StartWeek.DayOfYear) &&
                                                                   children.ChildrenGroups.FirstOrDefault(y => y.Group == x.Group) != null).ToList());
            }
        }
Beispiel #2
0
    public override string ToString()
    {
        var exams = Lessons.Where(x => x.StartTime.Date > Date.Date).ToArray();

        if (!exams.Any())
        {
            return("На данный момент список экзаменов отсутствует");
        }

        var strBuilder = new StringBuilder();
        var grouped    = exams.GroupBy(x => x.Name);

        foreach (var group in grouped)
        {
            var first = group.First();
            var last  = group.Last();

            strBuilder.AppendFormat("{0:D}:", first.StartTime).AppendLine();

            strBuilder.AppendFormat("{0:HH:mm}-{1:HH:mm} - {2} [{3}] ({4})",
                                    first.StartTime, last.EndTime, first.Name, first.Type, first.Teacher)
            .AppendLine()
            .AppendFormat("У группы {0}", first.Groups).AppendLine()
            .AppendFormat("В аудитории {0} ({1})", first.Auditory, first.Address).AppendLine();

            strBuilder.AppendLine();
        }

        return(strBuilder.ToString());
    }
Beispiel #3
0
        public StartPage()
        {
            InitializeComponent();
            Lessons            = JsonConvert.DeserializeObject <List <Lesson> >(File.ReadAllText("Lessons.json"));
            DataContext        = this;
            StartLessonCommand = new Command <int>(ChooseLesson);
            var currentLesson = Lessons.Where(x => x.LessonNr == Settings1.Default.CurrentLesson);

            Lesson = currentLesson.Any() ? currentLesson.First() : Lessons.First();
        }
        private void DeleteSelectedLesson(object p)
        {
            Lesson lessonToRemove = Lessons.Where(l => l.Name.Equals(p as string)).First();

            Lessons.Remove(lessonToRemove);
            using (var db = Database.Instance.GetConnection())
            {
                foreach (Word word in CurrentLessonWords)
                {
                    RemoveWordIfExists(db, word);
                }
                RemoveLessonIfExists(db, lessonToRemove);
            }
        }
Beispiel #5
0
 public virtual IEnumerable <Lesson> GetLessonsBySport(string sportName)
 {
     return(Lessons.Where(l => l.Group.Sport.Name == sportName));
 }