public IActionResult Index(ProductFilter filter = null) { try { var courses = _productRepo.getQueryable(); if (!string.IsNullOrWhiteSpace(filter.title)) { courses = courses.Where(a => a.name.Contains(filter.title)); } ViewBag.pagerInfo = _paginatedMetaService.GetMetaData(courses.Count(), filter.page, filter.number_of_rows); courses = courses.Skip(filter.number_of_rows * (filter.page - 1)).Take(filter.number_of_rows); var coursesDetails = courses.ToList(); CourseIndexViewModel productIndexVM = getProductIndexVM(coursesDetails); return(View(productIndexVM)); } catch (Exception ex) { AlertHelper.setMessage(this, ex.Message, messageType.error); return(Redirect("/admin")); } }
public IActionResult Index() { var model = new CourseIndexViewModel(); model.Courses = _courseData.GetAllCourses(); return(View(model)); }
public ActionResult Index() { IEnumerable <CourseDto> models = _universityService.ListCourses(); var viewModel = new CourseIndexViewModel(models); return(View(viewModel)); }
public ActionResult Index(int?fid, string session) { var civm = new CourseIndexViewModel(); if (fid.HasValue) { civm.Courses = _db.Courses.Include(c => c.CourseAssignments.Select(ca => ca.Managers.Select(m => m.User))) .Where(c => c.Faculties.Any(f => f.Id == fid.Value)) .ToList(); } else { civm.Courses = _db.Courses.Include(c => c.CourseAssignments.Select(ca => ca.Managers.Select(m => m.User))).ToList(); } if (!string.IsNullOrEmpty(session)) { var years = session.Split('-'); var sYear = Convert.ToInt32(years[0]); civm.SYear = sYear; } civm.Faculties = _db.Faculties.ToList(); return(View(civm)); }
public ActionResult Index() { List <CourseIndexViewModel> model = GetCourses() .Select(course => CourseIndexViewModel.GenerateNewViewModel(course)) .ToList(); return(View(model)); }
public IActionResult Index() { var course = new CourseIndexViewModel(); course.listCourse = _repositoryCourse.GetAllCourse(); course.CurrentMensage = "Course"; return(View(course)); }
public ActionResult Index() { var currentUser = UserUtils.GetCurrentUser(HttpContext); Course course = db.Courses.Find(currentUser.CourseId); CourseIndexViewModel cdvm = course; return(View(cdvm)); }
public IActionResult Index() { var courses = _courseService.GetAllCourses(); var courseIndexViewModel = new CourseIndexViewModel { Courses = courses }; return(View(courseIndexViewModel)); }
public ActionResult Index() { var List = db.CourseCategories.ToList(); var model = new CourseIndexViewModel() { CategoryList = List }; return(View(model)); }
private CourseIndexViewModel getProductIndexVM(List <Courses> coursesDetails) { CourseIndexViewModel vm = new CourseIndexViewModel(); vm.courses = new List <CourseDetail>(); foreach (var product in coursesDetails) { var convertedProduct = _mapper.Map <CourseDetail>(product); vm.courses.Add(convertedProduct); } return(vm); }
public ActionResult CourseEdit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Course course = db.Courses.Find(id); if (course == null) { return(HttpNotFound()); } CourseIndexViewModel civm = course; return(View(civm)); }
// GET: Courses public async Task <IActionResult> Index(int?courseId) { var viewModel = new CourseIndexViewModel(); viewModel.Courses = await _context.Courses .Include(i => i.Enrollments) .ThenInclude(i => i.Student) .AsNoTracking() .ToListAsync(); if (courseId.HasValue) { var students = await _context.Students.Where(s => s.Enrollments.Any(e => e.CourseId == courseId)).ToListAsync(); viewModel.Students = students; } return(View(viewModel)); }
public IActionResult Index(string category, string filter) { var vm = new CourseIndexViewModel(); string city = ((string.Compare(filter, "Mine", true) == 0) ? GetCity() : string.Empty); bool filterThisMonth = (string.Compare(filter, "ThisMonth", true) == 0); bool filterNextMonth = (string.Compare(filter, "NextMonth", true) == 0); vm.Courses = _courseService.GetCourses(city, category, filterThisMonth, filterNextMonth); if (DateTime.Now.Second >= 45) { throw new System.Exception("kaboom"); } if (DateTime.Now.Second > 10 && DateTime.Now.Second < 15) { System.Threading.Thread.Sleep(new TimeSpan(0, 0, 13)); } return(View(vm)); }
public IActionResult Search(CourseIndexViewModel courseIndexViewModel) { var getAllCoursesResponse = _courseService.GetAll(new GetAllCoursesRequest { SearchString = courseIndexViewModel.SearchString }); if (getAllCoursesResponse.IsSuccess == true) { return(View( "Index", new CourseIndexViewModel() { CourseViews = getAllCoursesResponse.CourseViews, })); } else { ModelState.AddModelError(string.Empty, "Loading Error"); return(View("Index")); } }
public CourseIndexViewModel GetCourseIndex(string slug, bool isAuthenticated = false) { var target = new CourseIndexViewModel { }; if (isAuthenticated) { var result = _context.Course.Include(x => x.Lessons).FirstOrDefault(x => x.Slug == slug); if (result != null) { var category = _context.Category.Find(result.CategoryId); if (category != null) { target.Category = category.Name; target.CategorySlug = category.Slug; } target.CourseId = result.CourseId; target.Name = result.Name; target.Slug = result.Slug; foreach (var item in result.Lessons) { var topics = _context.Topic.Where(x => x.LessonId == item.LessonId); List <TopicIndexViewModel> newTopics = new List <TopicIndexViewModel>(); foreach (var subItem in topics) { newTopics.Add(new TopicIndexViewModel { Name = subItem.Title, Slug = subItem.Slug, TopicId = subItem.TopicId }); } target.Lessons.Add(new LessonIndexViewModel { LessonId = item.LessonId, Name = item.Name, Slug = item.Slug, Topics = newTopics }); } } } else { var result = _context.Course.Include(x => x.Lessons).FirstOrDefault(x => x.Slug == slug && x.IsActive); if (result != null) { var category = _context.Category.Find(result.CategoryId); if (category != null) { target.Category = category.Name; target.CategorySlug = category.Slug; } target.CourseId = result.CourseId; target.Name = result.Name; target.Slug = result.Slug; foreach (var item in result.Lessons) { var topics = _context.Topic.Where(x => x.LessonId == item.LessonId && x.IsActive); List <TopicIndexViewModel> newTopics = new List <TopicIndexViewModel>(); foreach (var subItem in topics) { newTopics.Add(new TopicIndexViewModel { Name = subItem.Title, Slug = subItem.Slug, TopicId = subItem.TopicId }); } target.Lessons.Add(new LessonIndexViewModel { LessonId = item.LessonId, Name = item.Name, Slug = item.Slug, Topics = newTopics }); } } } return(target); }
public IActionResult Index() { var courseIndexViewModel = new CourseIndexViewModel(_courseRepository.GetAll()); return(View(courseIndexViewModel)); }