예제 #1
0
        public async Task <IActionResult> CreateLesson(string id)
        {
            var course = await this.coursesService.GetByIdAsync <CourseViewModel>(id);

            var viewModel = new CreateLessonInCourseInputModel()
            {
                CourseId     = id,
                CourseTitle  = course.Title,
                CategoryName = course.CategoryName,
                CategoryId   = course.CategoryId,
            };

            return(this.View(viewModel));
        }
예제 #2
0
        public async Task <IActionResult> CreateLesson(CreateLessonInCourseInputModel model)
        {
            if (!this.ModelState.IsValid)
            {
                var course = await this.coursesService.GetByIdAsync <CourseViewModel>(model.CourseId);

                model.CourseId     = model.CourseId;
                model.CourseTitle  = course.Title;
                model.CategoryName = course.CategoryName;
                model.CategoryId   = course.CategoryId;

                return(this.View(model));
            }

            var userId = this.User.FindFirst(ClaimTypes.NameIdentifier).Value;

            await this.lessonsService.CreateAsync(model.Title, model.Description, model.VideoUrl, userId, model.CategoryId, model.CourseId);

            return(this.RedirectToAction(nameof(this.Edit), new { id = model.CourseId }));
        }