public CertificationVM GetByUrlName(string urlName) { var certification = CertificationService.GetAll().ByUrlName(urlName); if (certification.IsNull()) { return(null); } var tracks = certification.Exams.SelectMany(e => e.Courses) .Where(c => c.IsTrack.GetValueOrDefault()).Distinct().ToList(); var trainers = EmployeeCertificationService.GetAll( x => x.Certification_ID == certification.Certification_ID && x.Certification.IsActive) .Select(x => x.Employee).Where(x => x.SiteVisible).Take(20).ToList(); var children = new List <Certification>(); if (!certification.Exams.Any()) { children = CertificationService.GetAll().IsActive() .Where(c => c.UrlName.StartsWith(certification.UrlName) && c.UrlName != certification.UrlName).OrderBy(x => x.SortOrder) .ToList(); } var groups = certification.Exams.Any() ? GetCertificationGroups(_.List(certification.Certification_ID)) : GetCertificationGroups(children.Select(x => x.Certification_ID).ToList()); var model = new CertificationVM { Certification = certification, Children = children, Tracks = TrackService.GetTrackDiscounts(tracks).ToList(), Groups = groups, Trainers = trainers }; if (model.IsMicrosoft) { model.Actions = MarketingActionService.GetAll(x => x.Type == MarketingActionType.Microsoft && !x.IsSecret && x.IsActive).ToList(); } return(model); }
public ActionResult AboutTrainer(string employeeTC, string urlName, int?pageIndex) { if (employeeTC.IsEmpty()) { return(NotFound()); } if (!pageIndex.HasValue && urlName.In( SimplePages.Urls.TrainerOrgResponses, SimplePages.Urls.TrainerResponses, SimplePages.Urls.TrainerTests, SimplePages.Urls.TrainerAdvices, SimplePages.Urls.TrainerWorks, SimplePages.Urls.TrainerVideos)) { return(RedirectToAction(() => AboutTrainer(employeeTC, urlName, 1))); } var index = pageIndex.GetValueOrDefault() - 1; var model = new AboutTrainerVM(); model.UrlName = urlName; model.Page = GetAboutTrainer(); employeeTC = employeeTC.ToUpper(); model.Employee = EmployeeVMService.GetEmployee(employeeTC); if (model.Employee == null || !model.Employee.Employee.IsTrainer) { return(Redirect(SimplePages.FullUrls.Trainers)); } var orgResponses = OrgResponseService.GetAll().IsActive() .Where(r => ("," + r.Employee_TC + ",").Contains("," + employeeTC + ",")) .OrderByDescending(o => o.UpdateDate); var responses = ResponseService.GetAllForEmployee(employeeTC) .OrderByDescending(x => x.Course.IsActive) .ThenByDescending(o => o.Rating).ThenByDescending(x => x.UpdateDate); var advices = AdviceService.GetAll().IsActive() .Where(r => r.Employee_TC == employeeTC) .OrderByDescending(o => o.UpdateDate); var tests = TestService.GetAll().Where(x => x.Status == TestStatus.Active) .Where(r => r.Author_TC == employeeTC) .OrderByDescending(o => o.Id); var videos = VideoService.GetAll().IsActive() .Where(r => r.Employee_TC == employeeTC) .OrderByDescending(o => o.VideoID); var userWorks = UserWorkService.GetAll().IsActive() .Where(r => r.Trainer_TC == employeeTC) .OrderByDescending(o => o.UserWorkID); model.HasOrgResponses = orgResponses.Any(); model.HasResponses = responses.Any(); model.HasAdvices = advices.Any(); model.HasTests = tests.Any(); model.HasVideos = videos.Any(); model.HasPortfolio = Images.GetGallaryFiles(model.Employee.Employee, "Portfolio").Any(); model.HasWorks = userWorks.Any(); if (model.IsTrainerResponses) { model.Responses = responses.ToPagedList(index, 20); } if (model.IsTrainerOrgResponses) { model.OrgResponses = orgResponses.ToPagedList(index, 10);; } if (model.IsAdvices) { model.Advices = advices.ToPagedList(index, 10); } if (model.IsTests) { model.Tests = tests.ToPagedList(index, 10); } if (model.IsVideos) { model.Videos = videos.ToList(); } if (model.IsWorks) { model.UserWorks = userWorks.ToPagedList(index, 10); } if (model.IsAboutTrainer) { model.Certifications = EmployeeCertificationService.GetAll( x => x.EmployeeFK_TC == employeeTC && x.Certification.IsActive) .OrderBy(x => x.SortOrder) .Select(x => x.Certification).ToList(); } return(View(model)); }