public async Task <CourseModuleModel> CreateCourseModule(CourseModuleModel model) { var track = await _portalContext.CourseModules.AddAsync(Mapper.Map <CourseModuleEntity>(model)); await _portalContext.SaveChangesAsync(); return(Mapper.Map <CourseModuleModel>(track.Entity)); }
public async Task <ActionResult> UpdateModule([FromBody] CourseModuleModel module, long courseId) { if (module.CourseId != courseId) { return(BadRequest()); } return(Ok(await _dbAccess.UpdateCourseModule(module))); }
// GET: Admin/CourseModule/Create public async Task <ActionResult> Create() { var model = new CourseModuleModel { Modules = await db.Modules.ToListAsync(), Courses = await db.Courses.ToListAsync() }; return(View(model)); }
public async Task <ActionResult> CreateModule([FromBody] CourseModuleModel module, long courseId) { if (module == null || module.CourseId != courseId) { return(BadRequest()); } module.PopulateServiceFields(Request.HttpContext); return(Ok(await _dbAccess.CreateCourseModule(module))); }
public static async Task <CourseModuleModel> Convert( this CourseModule courseModule, ApplicationDbContext db, bool addListData = true) { var model = new CourseModuleModel { ModuleId = courseModule.ModuleId, CourseId = courseModule.CourseId, Modules = addListData ? await db.Modules.ToListAsync() : null, Courses = addListData ? await db.Courses.ToListAsync() : null, ModuleTitle = (await db.Modules.FirstOrDefaultAsync(i => i.Id.Equals(courseModule.ModuleId))).Title, CourseTitle = (await db.Courses.FirstOrDefaultAsync(p => p.Id.Equals(courseModule.CourseId))).Title }; return(model); }
public CourseController() { _courseModel = new CourseModel(); _courseBatchModel = new CourseBatchModel(); _courseModuleModel = new CourseModuleModel(); }