public ActionResult GetIndustriesControl() { var industryModels = new List<IndustryModel>(); foreach (var industry in _context.Industries.Where(i => i.Culture == _curCult || String.IsNullOrEmpty(i.Culture)).ToList()) { var industryModel = new IndustryModel { Headline = industry.Headline, LinkPath = industry.LinkPath, PublishDate = industry.PublishDate.ToString("yyyy-MM-dd"), Id = industry.Id.ToString(), Index = industry.ListWeight }; var projectsForIndustry = new List<String>(); var publicationsForIndustry = new List<String>(); if (industry.Publications != null) foreach (var publication in industry.Publications.Where(pr => pr.Culture == _curCult).ToList()) { publicationsForIndustry.Add(publication.Headline); } industry.Publications.Sort((a, b) => b.PublishDate.CompareTo(a.PublishDate)); if (industry.Projects != null) foreach (var project in industry.Projects.Where(pr => pr.Culture == _curCult).ToList()) { projectsForIndustry.Add(project.Headline); } industry.Projects.Sort((a, b) => b.PublishDate.CompareTo(a.PublishDate)); industryModel.Projects = projectsForIndustry; industryModel.Publications = publicationsForIndustry; industryModels.Add(industryModel); } var allProjects = new List<ProjectModel>(); if (_context.Projects != null) foreach (var project in _context.Projects.Where(i => i.Culture == _curCult || String.IsNullOrEmpty(i.Culture)).ToList()) { allProjects.Add(new ProjectModel { Id = project.Id.ToString(), Headline = project.Headline, LinkPath = project.LinkPath, PublishDate = project.PublishDate.ToString("yyyy-MM-dd") }); } var allPublications = new List<PublicationModel>(); if (_context.Publications != null) foreach (var publication in _context.Publications.Where(i => i.Culture == _curCult || String.IsNullOrEmpty(i.Culture)).ToList()) { allPublications.Add(new PublicationModel { Id = publication.Id.ToString(), Headline = publication.Headline, LinkPath = publication.LinkPath, PublishDate = publication.PublishDate.ToString("yyyy-MM-dd") }); } var model = new IndustriesModel { Industries = industryModels, AllPublications = allPublications, AllProjects = allProjects }; model.AllProjects.Sort((a, b) => b.PublishDate.CompareTo(a.PublishDate)); model.AllPublications.Sort((a, b) => b.PublishDate.CompareTo(a.PublishDate)); return PartialView("_Industries", model); }
public ActionResult Index() { var model = new ProjectsViewViewModel { Industries = new List<IndustryModel>(), Practicies = new List<PracticeModel>() }; foreach (var practice in _context.Practicies.Where(i => i.Culture == _curCult || String.IsNullOrEmpty(i.Culture)).ToList()) { var practiceModel = new PracticeModel { Headline = practice.Headline, LinkPath = practice.LinkPath, PublishDate = practice.PublishDate.ToString("yyyy-MM-dd"), Id = practice.Id.ToString(), Index = practice.ListWeight }; var projectsForPractice = new List<string>(); var publicationsForPractice = new List<string>(); if (practice.Publications != null) foreach (var publication in practice.Publications.Where(i => i.Culture == _curCult || String.IsNullOrEmpty(i.Culture)).ToList()) { publicationsForPractice.Add(publication.Headline); } if (practice.Projects != null) foreach (var project in practice.Projects.Where(i => i.Culture == _curCult || String.IsNullOrEmpty(i.Culture)).ToList()) { projectsForPractice.Add(project.Headline); } practiceModel.Projects = projectsForPractice; practiceModel.Publications = publicationsForPractice; model.Practicies.Add(practiceModel); } foreach (var industry in _context.Industries.Where(i => i.Culture == _curCult || String.IsNullOrEmpty(i.Culture)).ToList()) { var industryModel = new IndustryModel { Headline = industry.Headline, LinkPath = industry.LinkPath, PublishDate = industry.PublishDate.ToString("yyyy-MM-dd"), Id = industry.Id.ToString(), Index = industry.ListWeight }; var projectsForIndustry = new List<String>(); var publicationsForIndustry = new List<String>(); if (industry.Publications != null) foreach (var publication in industry.Publications.ToList()) { publicationsForIndustry.Add(publication.Headline); } if (industry.Projects != null) foreach (var project in industry.Projects.ToList()) { projectsForIndustry.Add(project.Headline); } industryModel.Projects = projectsForIndustry; industryModel.Publications = publicationsForIndustry; model.Industries.Add(industryModel); } model.SearchedKeyword = string.Empty; model.SelectedPractice = null; model.SelectedProject = null; var projectsModels = new List<ProjectModel>(); foreach (var projectItem in _context.Projects.Where(i => i.Culture == _curCult || String.IsNullOrEmpty(i.Culture)).ToList()) { projectsModels.Add(new ProjectModel { Headline = projectItem.Headline, LinkPath = projectItem.LinkPath, PublishDate = projectItem.PublishDate.ToString("yyyy-MM-dd"), Id = projectItem.Id.ToString() }); } model.DisplayedProjects = projectsModels; return View(model); }