コード例 #1
0
 public CourseMenuPanel(IAccountService accountService, CourseModel courseModel)
     :this()
 {
     _accountService = accountService;
     _courseModel = courseModel;
     _courseModel = courseModel;
 }
コード例 #2
0
        public async Task<int> AddDeepCourse(CourseModel courseModel)
        {
            using (var dbContext = new EduTestEntities())
            {
                var course = new Course()
                {
                    Name = courseModel.Name,
                    Modules = courseModel.Modules.Select(m => new Module()
                    {
                       Name = m.Name,
                       Chapters = m.Chapters.Select(c => new Chapter()
                       {
                           Name = c.Name,
                           Topics = c.Topics.Select(t => new Topic()
                           {
                               Name = t.Name                               
                           }).ToList()
                       }).ToList()
                    }).ToList()
                };

                dbContext.Courses.Add(course);

                if (await dbContext.SaveChangesAsync() < 0)
                    throw new Exception("CoursesRepository.AddCourse: Could not add course to db");

                return course.Id;
            }
        }
コード例 #3
0
        public async Task<int> AddCourse(CourseModel courseModel)
        {
            using (var dbContext = new EduTestEntities())
            {
                var course = new Course()
                {
                    Name = courseModel.Name
                };

                dbContext.Courses.Add(course);

                if (await dbContext.SaveChangesAsync() < 0)
                    throw new Exception("CoursesRepository.AddCourse: Could not add course to db");

                return course.Id;
            }
        }
コード例 #4
0
        public async Task UpdateCourse(int id, CourseModel courseModel)
        {
            throw new NotImplementedException();
            /*using (var dbContext = new EduTestEntities())
            {
                var course = await dbContext.Courses.FirstOrDefaultAsync(c => c.Id == id);                               

                var course = new Course()
                {
                    Name = courseModel.Name,
                    Modules = courseModel.Modules.Select(m => new Module()
                    {
                        Name = m.Name,
                        Chapters = m.Chapters.Select(c => new Chapter()
                        {
                            Name = c.Name,
                            Topics = c.Topics.Select(t => new Topic()
                            {
                                Name = t.Name
                            }).ToList()
                        }).ToList()
                    }).ToList()
                };                

                if (await dbContext.SaveChangesAsync() < 0)
                    throw new Exception("CoursesRepository.UpdateCourse: Could not update course");
            }*/
        }
コード例 #5
0
 public static void GetCurseMenuPanel(IAccountService accountService, CourseModel courseModel)
 {            
     InitTopMenuPanel(new CourseTopMenuPanel(accountService, courseModel));
     InitContentPanel(new CourseMenuPanel(accountService, courseModel));                       
 }
コード例 #6
0
 private void InitCourseTreeView(CourseModel currentCourseModel)
 {
     moduleList = new ObservableCollection<ObservableModuleModel>(ConvertToObservable(currentCourseModel.Modules));
     CoursesTreeView.DataContext = moduleList;
 }