Exemple #1
0
        protected override List <object> GetValuesForRow(Product item)
        {
            var values      = base.GetValuesForRow(item);
            var vendors     = SiteObjectService.GetSingleRelation <Vendor>(item);
            var entityLinks = new ListVM.EntityLinkList();

            var metaData = MetaDataProvider.Get(typeof(Vendor));

            foreach (var vendor in vendors)
            {
                entityLinks.Add(new ListVM.EntityLink(vendor, metaData, Url));
            }
            values.Add(entityLinks);
            return(values);
        }
Exemple #2
0
        List <string> GetCourseTagLinks(Course c)
        {
            var x1 = SiteObjectService.GetSingleRelation <Vendor>(c).ToList()
                     .Select(x => H.Anchor(Html.GetUrlFor(x), x.Name));
            var x2 = SiteObjectService.GetSingleRelation <Section>(c).ToList()
                     .Select(x => H.Anchor(Html.GetUrlFor(x), x.Name));
            var x3 = SiteObjectService.GetSingleRelation <Product>(c).ToList()
                     .Select(x => H.Anchor(Html.GetUrlFor(x), x.Name));
            var x4 = SiteObjectService.GetSingleRelation <Profession>(c).ToList()
                     .Select(x => H.Anchor(Html.GetUrlFor(x), x.Name));
            var x5 = SiteObjectService.GetSingleRelation <SiteTerm>(c).ToList()
                     .Select(x => H.Anchor(Html.GetUrlFor(x), x.Name));

            return(x1.Concat(x2).Concat(x3).Concat(x4).Concat(x5)
                   .Select(x => x.AbsoluteHref().ToString()).ToList());
        }
Exemple #3
0
        public MobileCourseVM GetMobileByUrlName(string urlName)
        {
            var course = CourseService.GetByUrlName(urlName);

            if (course == null)
            {
                return(null);
            }
            var section = SiteObjectService.GetSingleRelation <Section>(course)
                          .IsActive().OrderBy(x => x.IsMain).FirstOrDefault();
            var model = new MobileCourseVM {
                Course  = course,
                Groups  = GroupService.GetGroupsForCourse(course.Course_TC).ToList(),
                Section = section
            };

            model.Prices = PriceService.GetAllPricesForCourse(course.Course_TC, null);
            return(model);
        }
Exemple #4
0
        public List <TagWithEntity> GetTags(string courseTC)
        {
            var result = new List <TagWithEntity>();
            var course = new Course {
                Course_TC = courseTC
            };
            var products = SiteObjectService.GetSingleRelation <Product>(course);

            foreach (var product in products)
            {
                result.Add(new TagWithEntity(product, 1 /*SiteObjectRelationService.GetWeight(product)*/));
            }
            var siteTerms = SiteObjectService.GetSingleRelation <SiteTerm>(course);

            foreach (var siteTerm in siteTerms)
            {
                result.Add(new TagWithEntity(siteTerm, 1 /*SiteObjectRelationService.GetWeight(siteTerm)*/));
            }

            return
                (result.Cast <TagWithEntity <object> >().ToList().Normalization().Cast <TagWithEntity>().ToList());
        }
Exemple #5
0
        public TrackVM GetByUrlName(string urlName)
        {
            var track = TrackService.GetByUrlName(urlName);

            if (track == null)
            {
                return(null);
            }
            var courseTC = track.Course_TC;
//            var certifications = CertificationService.
//                GetAllForCourse(courseTC);
            var sections = SiteObjectService.GetSingleRelation <Section>(track)
                           .IsActive().ByWebOrder().ToList();


            var prices = PriceService.GetAllPricesForCourse(courseTC, null);

            var courseTCs = _.List(courseTC);

            courseTCs.AddRange(CourseService.GetActiveTrackCourses().GetValueOrDefault(track.Course_TC)
                               ?? new List <string>());
            var certTypes = CourseCertificateService.GetAll(x => courseTCs.Contains(x.Course_TC))
                            .Select(x => new { x.Course_TC, x.CertType }).Distinct().ToList().Where(x =>
                                                                                                    x.Course_TC != courseTC || x.CertType.CertTypeName.Contains(CertTypes.InterName))
                            .Select(x => x.CertType).ToList();
            var trackDetailsVM =
                new TrackVM {
                Certifications      = new List <Certification>(),
                Course              = track,
                Prices              = prices,
                Sections            = sections,
                CertTypeList        = certTypes,
                CompleteCourseCount = StudentInGroupService.CompleteCountForTracks()
                                      .GetValueOrDefault(track.ParentCourse_TC)
            };

            return(trackDetailsVM);
        }
Exemple #6
0
        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);
        }