예제 #1
0
        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));
        }
예제 #2
0
        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));
        }
예제 #4
0
        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)));
        }
예제 #5
0
        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);
        }
예제 #6
0
 public CourseController()
 {
     _courseModel       = new CourseModel();
     _courseBatchModel  = new CourseBatchModel();
     _courseModuleModel = new CourseModuleModel();
 }