public CourseMenuPanel(IAccountService accountService, CourseModel courseModel) :this() { _accountService = accountService; _courseModel = courseModel; _courseModel = courseModel; }
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; } }
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; } }
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"); }*/ }
public static void GetCurseMenuPanel(IAccountService accountService, CourseModel courseModel) { InitTopMenuPanel(new CourseTopMenuPanel(accountService, courseModel)); InitContentPanel(new CourseMenuPanel(accountService, courseModel)); }
private void InitCourseTreeView(CourseModel currentCourseModel) { moduleList = new ObservableCollection<ObservableModuleModel>(ConvertToObservable(currentCourseModel.Modules)); CoursesTreeView.DataContext = moduleList; }