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 CourseVM GetByUrlName(string urlName) { var cityTC = UserSettingsService.CityTC; var course = CourseService.GetByUrlName(urlName); if (course == null) { return(null); } var courseTC = course.Course_TC; var nextCourseTCList = CourseService.GetNextCourseTCs(_.List(course.ParentCourse_TC)); var nextCourses = CourseService.GetCourseLinkList(nextCourseTCList).ToList() .OrderBy(x => nextCourseTCList.IndexOf(x.CourseTC)).ToList(); var notSecondCourseDiscount = CourseService.NotSecondCourses(); var secondCourse = SecondCourse(courseTC, nextCourses.Where(x => !notSecondCourseDiscount.Contains(x.CourseTC)).FirstOrDefault()); var successStories = SuccessStoryService.GetAll(x => x.Course_TC == courseTC).Take(1) .OrderByDescending(x => x.SuccessStoryID).ToList(); var responceCount = successStories.Any() ? 1 : 2; var responseQuery = ResponseService.GetAllForCourse(courseTC); var responses = responseQuery .Where(x => x.Rating >= ResponseRating.Good) .GetRandom(responceCount).ToList(); if (responses.Count < responceCount) { responses.AddRange(responseQuery .Where(x => x.Rating == ResponseRating.Common) .GetRandom(responceCount - responses.Count)); } if (!responses.Any()) { responses = ResponseService.GetAll(x => x.IsActive && x.Type == RawQuestionnaireType.OrganizingComment) .Take(responceCount).ToList(); } var responseTotalCount = responseQuery.Count(); var nearestGroups = GroupService.GetNearestGroups(course, cityTC); var trainers = nearestGroups.All .Select(x => x.Teacher).Where(e => e != null && e.SiteVisible) .Distinct(x => x.Employee_TC).ToList(); var morningDiscount = NearestGroupSet.HasMorningDiscount(nearestGroups.All); var product = SiteObjectService.GetSingleRelation <Product>(course) .IsActive().OrderByDescending(x => x.WebSortOrder).FirstOrDefault(); var prices = PriceService.GetAllPricesForCourse(course.Course_TC, null); var certifications = CertificationService.GetAllForCourse(courseTC); var vacancies = SuperJobService.GetVacancies( SiteObjectRelationService.GetRelation( typeof(Course), _.List(courseTC), typeof(Profession)) .Select(sor => (int)sor.RelationObject_ID) .ToList(), cityTC); var withWebinar = PriceService.CourseWithWebinar(); var discount30 = Discount30Courses(); var actions = GetActionOnCoursePages().Where(x => { var courseTCList = EntityUtils.GetCourseTCs(x, withWebinar); return(!courseTCList.Any() || courseTCList.Contains(courseTC) || (x.MarketingAction_ID == 150 && discount30.Contains(courseTC))); }).OrderBy(x => x.WebSortOrder).ToList(); if (course.IsExpensive) { actions = actions.Where(x => !x.CourseTCList.IsEmpty()).ToList(); } var preTestIds = course.CoursePrerequisites.Select(x => x .Test_ID.GetValueOrDefault()) .Where(x => x > 0).ToList(); var preTests = preTestIds.Any() ? TestService.GetAll(x => preTestIds.Contains(x.Id)).ToList() : new List <Test>(); var sections = SiteObjectService.GetSingleRelation <Section>(course) .IsActive().Where(x => !Sections.NotImportant.Contains(x.Section_ID)).ByWebOrder().ToList(); var tests = SiteObjectService.GetByRelationObject <Test>(course) .Where(x => x.Status == TestStatus.Active).ToList(); var visitedCourseTCs = UserSettingsService.VisitedCourses.Except(_.List(courseTC)).ToList(); var visitedCourses = CourseService.GetCourseLinkList(visitedCourseTCs).ToList(); visitedCourseTCs.Insert(0, courseTC); UserSettingsService.VisitedCourses = visitedCourseTCs; var courseContentTC = courseTC == "сопсв-ю" && Htmls.IsSecond ? CourseTC.WebText : courseTC; var courseContents = CourseContentService.GetAll(x => x.Course_TC == courseContentTC).ToList(); var certTypes = course.CourseCertificates.Select(cc => cc.CertType).Where(x => x.IsVisible).ToList(); var hasTracks = TrackService.GetAllTracksWithCourse(courseTC).Any(); var courseDetailsVM = new CourseVM { Course = course, SecondCourse = secondCourse, CourseInDiplom = CourseService.CoursesInDiploms().Contains(courseTC), PrerequisiteTests = preTests, HasPaperBook = ExtrasService.CoursesWithPaperBook().Contains(courseTC), Actions = actions, HasTracks = hasTracks, CourseContents = courseContents, Tests = tests, MaxDiscount = GroupService.GetGroupsForCourse(courseTC) .Where(x => !x.IsOpenLearning).Select(x => x.Discount).Max(), CompleteCourseCount = CompleteCountForCourses().GetValueOrDefault(courseTC), Responses = responses.ToList(), SuccessStories = successStories, NextCourses = nextCourses.ToList(), WebinarDiscount = PriceService.WebinarDiscouns().GetValueOrDefault(courseTC), NearestGroups = nearestGroups, Certifications = certifications, Prices = prices, MorningDiscount = morningDiscount, Trainers = trainers.ToList(), Vacancies = vacancies.ToList(), ResponseTotalCount = responseTotalCount, UnlimitPrice = PriceService.GetUnlimitPrice(courseTC), Sections = sections, Product = product, VisitedCourses = visitedCourses, CertTypeList = certTypes, WebinarDiscounts = PriceService.WebinarDiscouns() }; return(courseDetailsVM); }
public AllCourseListVM GetAll(object obj) { var courses = obj == null ? CourseService.AllCoursesForList() : CourseService.GetAllFor(obj); var track = obj as Course; var isTrack = track != null; var isTrackDiplom = track != null && courses.FirstOrDefault(x => x.Course_TC == track.Course_TC) .GetOrDefault(x => x.IsDiplom); var trackList = obj as TrackListVM; var siteTerm = obj as SiteTerm; var isIntraExtraTerm = siteTerm != null && siteTerm.SiteTerm_ID == Sections.Terms.IntraExtra; var isOpenClassesTerm = siteTerm != null && siteTerm.SiteTerm_ID == Sections.Terms.OpenClasses; var isDiplomPage = trackList != null && trackList.IsDiplomPage; var isTrainingProgramsPage = trackList != null && trackList.IsTrainingProgramsPage; if (isDiplomPage || isTrainingProgramsPage) { courses = courses.Where(x => trackList.Courses.Contains(x.Course_TC)).ToList(); } var isIntraExtraTrackPage = (isTrack && CourseService.IntraExtraTracks().Contains(track.Course_TC)) || isDiplomPage; var trackFullPrices = TrackService.TrackFullPrices(); var items = courses.Select(c => { var nearestGroupAndWebinar = GroupService.GetNearestGroupAndWebinar(c, isIntraExtraTrackPage || isIntraExtraTerm, isOpenClassesTerm); var coefficient = isTrack ? null : GroupService.GetGroupsForCourse(c.Course_TC).Where(x => !x.IsIntraExtramural) .Select(x => PriceUtils.GetCoefficient(x)).Min(); var prices = PriceService.GetAllPricesForCourse(c.Course_TC, null); var trackPrices = c.IsTrackBool ? trackFullPrices.GetValueOrDefault(c.Course_TC) : null; return(new CommonCourseListItemVM { Course = c, IsIntraExtraTrackPage = isIntraExtraTrackPage, IsTrackPage = isTrack, TrackFullPrices = trackPrices, NearestGroup = nearestGroupAndWebinar.Item1, NearestWebinar = nearestGroupAndWebinar.Item2, Prices = prices, PriceCoefficent = coefficient }); }) .ToList(); var commonCourseListVM = new CommonCourseListVM { Items = items, IsTrackPage = isTrack, IsDiplomPage = isDiplomPage, IsTrainingProgramsPage = isTrainingProgramsPage }; return (new AllCourseListVM { MainList = courses, TrackCounts = CourseService.TrackCourseCounts(), TrackLastCourseDiscounts = TrackService.TrackLastCourseDiscounts(), Common = commonCourseListVM, IsTrack = isTrack, IsDiplomPage = isDiplomPage, IsTrainingProgramsPage = isTrainingProgramsPage, IsIntraExtra = isIntraExtraTrackPage, IsTrackDiplom = isTrackDiplom, HideIntraGroup = isIntraExtraTerm || isOpenClassesTerm, IsOpenClasses = isOpenClassesTerm, CourseWithUnlimit = PriceService.CourseWithUnlimite(), }); }