Ejemplo n.º 1
0
        public CourseViewModel(int id)
        {
            this.Lectures = new ObservableCollection <LectureViewModel>();
            LoadData.GetCourseById(id, AppCache.Config.AccessToken, c =>
            {
                this.Name            = c.CourseTitle;
                this.StartDate       = c.StartDate;
                this.EndDate         = c.EndDate;
                this.LecturesPerWeek = c.LecturesPerWeek;
                this.SignUpDeadline  = c.SignUpDeadline;
                this.Description     = c.Description;

                foreach (var lecture in c.Lectures)
                {
                    var newLecture = new LectureViewModel
                    {
                        Id               = lecture.Id,
                        Name             = lecture.Name,
                        HomeworkDeadline = lecture.HomeworkDeadline
                    };

                    foreach (var homework in lecture.Homeworks)
                    {
                        var newHomework = new HomeworkViewModel
                        {
                            Id = homework.Id, FileName = homework.FileName
                        };

                        newLecture.Homeworks.Add(newHomework);
                    }

                    this.Lectures.Add(newLecture);
                }
            });
        }
Ejemplo n.º 2
0
        private void HandleAddLecture(object parameter)
        {
            var newLecture = new AddLectureModel();

            LoadData.CreateLectures(newLecture, AppCache.Config.AccessToken, this.Id, () =>
            {
                var lecture              = new LectureViewModel();
                lecture.Name             = newLecture.Name;
                lecture.HomeworkDeadline = newLecture.HomeworkDeadline;
                this.Lectures.Add(lecture);
            });
        }