Пример #1
0
        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));
        }
Пример #2
0
 /*	public List<string> GetBreadCrumbs(GroupsWithDiscountVM model) {
  *      var breadcrumb = new List<string>();
  *          AddLink(breadcrumb, model.Course);
  *          return breadcrumb;
  *  }*/
 public List <string> GetBreadCrumbs(AboutTrainerVM model)
 {
     return(GetBreadCrumbs(SimplePageService.GetAll()
                           .SysName(SimplePages.Trainers), true));
 }