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)); }
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 })); }