public IActionResult UploadContent(int id) { var course = _courseData.GetFullCourse(id); var courseTaskViewModel = new List <CourseTaskViewModel>(); foreach (var section in course.Sections) { foreach (var sectionTopic in section.Topics) { foreach (var sectionTopicVideoTask in sectionTopic.VideoTasks) { courseTaskViewModel.Add(new CourseTaskViewModel { VideoExist = !string.IsNullOrEmpty(sectionTopicVideoTask.VideoUrl), TopicName = sectionTopic.Name, TaskName = sectionTopicVideoTask.Name, VideoTaskId = sectionTopicVideoTask.Id, CourseId = course.Id }); } } } var model = new UploadContentViewModel { CourseId = course.Id, Models = courseTaskViewModel, CourseImage = course.ImageUrl }; return(View(model)); }
public async Task <IActionResult> UploadCourseImage(UploadCourseCover model) { if (!ModelState.IsValid) { return(BadRequest()); } var course = _courseData.GetFullCourse(model.CourseId); if (course == null) { return(NotFound()); } string path = _hostingEnv.WebRootPath + $"{Path.DirectorySeparatorChar}images{Path.DirectorySeparatorChar}coursesMainImages{Path.DirectorySeparatorChar}" + model.File.FileName; using (var fileStream = new FileStream(path, FileMode.Create)) { await model.File.CopyToAsync(fileStream); } var urlPath = $"/images/coursesMainImages/{model.File.FileName}"; course.ImageUrl = urlPath; course.LocalImageUrl = path; _courseData.UpdateCourse(course); return(Ok(new { ImageUrl = urlPath })); }
public async Task <IViewComponentResult> InvokeAsync(int idOfCourse) { var viewSections = new List <SectionViewModel>(); var course = _courseData.GetFullCourse(idOfCourse); foreach (var section in course.Sections) { var topics = new List <SectionViewModel>(); var sectionViewModel = new SectionViewModel { ParentSection = null, Name = section.Name, Id = section.Id, ChildSections = null }; foreach (var topic in section.Topics) { topics.Add(new SectionViewModel { ParentSection = sectionViewModel, Name = topic.Name, Id = topic.Id }); } sectionViewModel.ChildSections = topics; viewSections.Add(sectionViewModel); } return(View(viewSections)); }
public IActionResult DeleteCourse(int id) { var course = _data.GetFullCourse(id); _data.DeleteCourse(course); return(Ok()); }
public async Task <IActionResult> AddCourse(int courseId) { var course = _data.GetFullCourse(courseId); var userId = User.GetUserId(); var user = _userData.GetUserWithStats(userId); user.CourseStatistics.Add(CreateStatisticsForCourse(course)); _userData.UpdateUser(user); _userData.AddCourseToUser(course, user); return(RedirectToAction("Details", "Course", new { id = courseId })); }
public IActionResult Details(int id) { var course = _courseData.GetFullCourse(id); return(View(course)); }
public IActionResult GetCourses() { return(Ok(_data.GetFullCourse().Select(c => _mapper.Map <Course, CourseDto>(c)))); }
public IActionResult Course(int id) { var course = _data.GetFullCourse(id); return(View(course)); }