public ActionResult UserWorksFor(object obj) { var userWorks = new List <UserWork>(); if (obj is Section) { userWorks = UserWorkService.GetAllRandomForSection( obj.As <Section>().Section_ID) .Take(3).ToList(); } else if (obj is Course) { userWorks = UserWorkService.GetAllRandomForBlock() .Where(uw => uw.Course_TC.Contains( obj.As <Course>().Course_TC)).Take(3).ToList(); } else if (obj is Product) { var userWorkSectionId = UserWorkSections.Products.GetValueOrDefault( obj.As <Product>().Product_ID); if (userWorkSectionId > 0) { userWorks = UserWorkService.GetAllRandomForBlock() .Where(uw => uw.WorkSectionID == userWorkSectionId).Take(3).ToList(); } } return(View(PartialViewNames.UserWorkBlock, userWorks)); }
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)); }
private void UpdateEntityStudySets(ResponseUpdateView model, Func <string, string> comma) { var entitySets = EntityStudySetService.GetAll().Select(uw => new { courseTCs = "," + uw.CourseTCList.Replace(" ", "") + ",", uw }) .Where(x => x.courseTCs.Contains(comma(model.FromCourseTC))).ToList(); foreach (var entitySet in entitySets) { var newCourseTCs = entitySet.courseTCs.Replace(comma(model.FromCourseTC), comma(model.ToCourseTC)); entitySet.uw.CourseTCList = newCourseTCs.Trim(','); } UserWorkService.SubmitChanges(); }
private int UpdateUserWorks(ResponseUpdateView model, Func <string, string> comma) { var userWorks = UserWorkService.GetAll().Select(uw => new { courseTCs = "," + uw.Course_TC.Replace(" ", "") + ",", uw }) .Where(x => x.courseTCs.Contains(comma(model.FromCourseTC))).ToList(); foreach (var userWork in userWorks) { var newCourseTCs = userWork.courseTCs.Replace(comma(model.FromCourseTC), comma(model.ToCourseTC)); userWork.uw.Course_TC = newCourseTCs.Trim(','); } UserWorkService.SubmitChanges(); return(userWorks.Count); }
public ActionResult UserWorks(int sectionID, int workSectionID, int?pageIndex) { if (!pageIndex.HasValue) { return(RedirectToAction(() => UserWorks(sectionID, workSectionID, 1))); } var index = pageIndex.Value - 1; var works = UserWorkService.GetAll().IsActive() .Where(uw => uw.Section_ID == sectionID); var model = new UserWorksVM { Section = SectionService.GetByPK(sectionID), }; if (workSectionID != 0) { model.WorkSection = UserWorkSectionService.GetByPK(workSectionID); works = works.Where(uw => uw.WorkSectionID == workSectionID); } model.UserWorks = works.OrderByDescending(uw => uw.UserWorkID) .ToPagedList(index, 10); return(View(model)); }
public ActionResult UserWorks(int sectionId) { var userWorks = UserWorkService.GetAllRandomForSection(sectionId).Take(4); return(Content(H.l(Html.Site().UserWorkFour(userWorks)).ToString())); }
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)); }
private List <int> GetSectionIdsContainUserWorks() { return(MethodBase.GetCurrentMethod().CacheDay(() => UserWorkService.GetAll(x => x.SmallImage != null) .Select(x => x.Section_ID).Distinct().ToList())); }