Exemple #1
0
        public virtual ActionResult Complex(string urlName)
        {
            ComplexService.LoadWith(b => b.Load(x => x.BranchOffice, x => x.Admin).And <BranchOffice>(x => x.City));
            var complex = ComplexService.GetAll().ByUrlName(urlName);

            if (complex == null)
            {
                return(null);
            }
            if (complex.Complex_TC == Cities.Complexes.Partners)
            {
                return(Redirect(SimplePages.FullUrls.Partners));
            }
            if (!complex.IsPublished)
            {
                return(RedirectToAction(() => City(complex.BranchOffice.City.UrlName)));
            }
            var responses = ResponseService.GetAll()
                            .IsActive().Where(x => x.Complex_TC == complex.Complex_TC)
                            .OrderByDescending(x => x.UpdateDate).ToList();
            var otherComplexes = ComplexService.GetAll(x => x.IsPublished &&
                                                       x.UrlName != urlName).ToList();
            var model = new ComplexVM
            {
                Complex         = complex,
                OtherComplexes  = otherComplexes,
                Responses       = responses,
                NearestGroupSet = GroupService.GetNearestGroups(complex),
                GeoLocation     = Cities.Complexes.GeoLocations.GetValueOrDefault(complex.Complex_TC)
            };

            return(MView(Views.Locations.Complex, model));
        }
        private List <TrainerInfoVM> GetTrainers()
        {
            var trainers = EmployeeService.GetAll(e => e.EmpGroup_TC ==
                                                  EmpGroups.Trainer).ToList();
            var trainerTCs     = trainers.Select(x => x.Employee_TC).ToList();
            var responseCounts = ResponseService.GetAll().IsActive()
                                 .Where(x => x.Type == RawQuestionnaireType.Teacher &&
                                        trainerTCs.Contains(x.Employee_TC))
                                 .GroupBy(x => x.Employee_TC)
                                 .Select(x => new { Key = x.Key.ToUpper(), Count = x.Count() })
                                 .ToDictionary(x => x.Key, x => x.Count);
            var groupCounts = GroupService.GetAll().PlannedAndNotBegin()
                              .Where(x => x.DateBeg < DateTime.Today.AddMonths(6) &&
                                     trainerTCs.Contains(x.Teacher_TC))
                              .GroupBy(x => x.Teacher_TC)
                              .Select(x => new { x.Key, Count = x.Count() })
                              .ToDictionary(x => x.Key, x => x.Count);

            return(trainers.Select(e => new TrainerInfoVM {
                Trainer = e,
                Link = HtmlControls.Anchor(Const.Common.SiteDomain + Html.GetUrlFor(e),
                                           e.FullName).ToString(),
                ResponseCount =
                    responseCounts.GetValueOrDefault(e.Employee_TC),
                HasPhoto = Urls.Employee(e.Employee_TC) != null,
                HasDescription = e.SiteDescription.GetOrDefault(x => x.Length > 50),
                Groups = groupCounts.GetValueOrDefault(e.Employee_TC)
            }
                                   ).Where(x => x.Trainer.SiteVisible || x.Groups > 0).ToList());
        }
Exemple #3
0
        public ActionResult PrivatePerson(string urlName, int?pageIndex)
        {
            if (!pageIndex.HasValue && urlName != SimplePages.Urls.Works)
            {
                return(RedirectToAction(() => PrivatePerson(urlName, 1)));
            }
            var index = pageIndex.GetValueOrDefault() - 1;

            var model = new PrivatePersonVM();

            model.UrlName = urlName;
            if (model.IsSuccessStories)
            {
                model.SuccessStories = SuccesStoryService.GetAll()
                                       .IsActive().OrderByDescending(s => s.SuccessStoryID).ToPagedList(index, 10);
            }

            else if (model.IsResponses)
            {
                model.Responses = ResponseService.GetAll().IsActive()
                                  .OrderByDescending(x => x.Rating)
                                  .ThenByDescending(r => r.ResponseID).ToPagedList(index, 10);
            }

            else if (model.IsUserWorks)
            {
                var temp =
                    (from x in UserWorkService.GetAll().IsActive()
                     where !x.Section.IsMain
                     group x by x.Section_ID
                     into gr
                     select
                     new {
                    Section = gr.Key,
                    WorkSections = gr.Select(x => x.UserWorkSection).Distinct()
                }).ToDictionary(x => x.Section, x => x.WorkSections.ToList());
                var tree         = SectionService.GetSectionsTree();
                var allSections  = temp.Select(x => x.Key).ToList();
                var rootSections =
                    tree.Select(x =>
                                new {
                    Root     = x,
                    Sections = x.SubSections.Where(ss =>
                                                   allSections.Contains(ss.Section_ID)).ToList()
                })
                    .Where(x => x.Sections.Any()).ToList();

                model.UserWorks = rootSections.Select(x => EntityWithList.New(x.Root,
                                                                              x.Sections.Select(y => EntityWithList.New(y,
                                                                                                                        temp.GetValueOrDefault(y.Section_ID)))))
                                  .ToList();
            }
            else
            {
                return(RedirectToAction(() => PrivatePerson(SimplePages.Urls.SuccessStories, 1)));
            }

            return(View(model));
        }
Exemple #4
0
        public MyResponses GetResponses(int index)
        {
            var user      = AuthService.CurrentUser;
            var responses = ResponseService.GetAll()
                            .Where(rq => rq.RawQuestionnaire.Questionnaire.Student_ID == user.Student_ID &&
                                   rq.IsActive)
                            .ToPagedList(index, 5);

            return(new MyResponses
            {
                Responses = responses,
            });
        }