public ActionResult searchResults() { TempData.Keep(); searchViewModel advancedSearch = (searchViewModel)TempData["search"]; if (advancedSearch == null) { return RedirectToAction("Index"); } //List<Indicators> indicatorList = db.Indicators.ToList(); List<Indicators> indicatorList = db.Indicators.Where(x => x.Area_ID.Equals(1)).Where(y => y.Indicator_CoE_Map.Any(x => x.CoE_ID.Equals(10) || x.CoE_ID.Equals(27) || x.CoE_ID.Equals(30) || x.CoE_ID.Equals(40) || x.CoE_ID.Equals(50))).ToList(); List<Indicators> indicatorListString = new List<Indicators>(); string searchString = advancedSearch.searchString; if (searchString != null) { string[] searchStrings; searchStrings = searchString.Split(' '); foreach (var sS in searchStrings) { indicatorList = indicatorList.Where(s => s.Indicator != null && s.Indicator.ToLower().Contains(sS.ToLower())).ToList(); } } List<Indicators> indicatorListCoE = new List<Indicators>(); List<selectedCoEs> searchCoEs; searchCoEs = advancedSearch.selectedCoEs; if (searchCoEs != null) { foreach (var coe in searchCoEs) { indicatorListCoE.AddRange(db.Indicators.Where(s => s.Indicator_CoE_Map.Any(x => x.CoE_ID == coe.CoE_ID)).ToList()); } indicatorList = indicatorList.Intersect(indicatorListCoE).ToList(); } List<Indicators> indicatorListAreas = new List<Indicators>(); List<selectedAreas> searchAreas; searchAreas = advancedSearch.selectedAreas; if (searchAreas != null) { foreach (var area in searchAreas) { indicatorListAreas.AddRange(db.Indicators.Where(s => s.Area_ID == area.Area_ID).ToList()); } indicatorList = indicatorList.Intersect(indicatorListAreas).ToList(); } List<Indicators> indicatorListTypes = new List<Indicators>(); List<selectedTypes> searchTypes; searchTypes = advancedSearch.selectedTypes; if (searchTypes != null) { foreach (var type in searchTypes) { indicatorListTypes.AddRange(db.Indicators.Where(s => s.Indicator_Type.Replace("/","").Replace("&","").Replace(" ","") == type.Indicator_Type).ToList()); } indicatorList = indicatorList.Intersect(indicatorListTypes).ToList(); } List<Indicators> indicatorListFootnotes = new List<Indicators>(); List<selectedFootnotes> searchFootnotes; searchFootnotes = advancedSearch.selectedFootnotes; if (searchFootnotes != null) { foreach (var footnote in searchFootnotes) { indicatorListFootnotes.AddRange(db.Indicators.Where(s => s.Indicator_Footnote_Map.Any(x => x.Footnote_ID == footnote.Footnote_ID)).ToList()); } indicatorList = indicatorList.Intersect(indicatorListFootnotes).ToList(); } if (ModelState.IsValid) { var viewModel = new indexViewModel { allIndicators = indicatorList.Distinct().ToList(), // allCoEs = db.CoEs.ToList(), // allAreas = db.Areas.ToList(), // allFootnotes = db.Footnotes.ToList() }; return View(viewModel); } return View(); }
public ActionResult indicatorList() { var indexViewModel = new indexViewModel() { allIndicators = db.Indicators.Where(x => x.Indicator_CoE_Map.FirstOrDefault().CoE_ID > 10 && x.Indicator_CoE_Map.FirstOrDefault().CoE_ID < 20).ToList(), allAnalysts = db.Analysts.ToList(), allAreas = db.Areas.Where(x => x.Area_ID == 1 || x.Area_ID == 3 || x.Area_ID == 4 || x.Area_ID == 5).ToList(), allCoEs = db.CoEs.Where(x => x.CoE_ID > 10 && x.CoE_ID < 20 && x.CoE_ID != 14).ToList(), allFootnotes = db.Footnotes.ToList(), }; return View(indexViewModel); }
public ActionResult Index() { /*var viewModel = new indexViewModel { allIndicators = db.Indicators.ToList(), allCoEs = db.CoEs.ToList(), allAreas = db.Areas.ToList(), allFootnotes= db.Footnotes.ToList() };*/ var viewModel = new indexViewModel { allIndicators = db.Indicators.ToList(), allCoEs = db.CoEs.Where(x => x.CoE_ID == 10 || x.CoE_ID == 27 || x.CoE_ID == 30 || x.CoE_ID == 40 || x.CoE_ID == 50).ToList(), allAreas = db.Areas.Where(x => x.Area_ID == 1).ToList(), //allFootnotes= db.Footnotes.Where(x => x.Footnote_ID == 9999).ToList() }; return View(viewModel); }
public ActionResult Index(Int16? fiscalYear) { if (!fiscalYear.HasValue) { fiscalYear = 2; } var indexViewModel = new indexViewModel(){ allIndicators = db.Indicators.Where(x => x.Indicator_CoE_Map.FirstOrDefault().CoE_ID > 10 && x.Indicator_CoE_Map.FirstOrDefault().CoE_ID < 20).ToList(), allAnalysts = db.Analysts.ToList(), allAreas = db.Areas.Where(x => x.Area_ID == 1 || x.Area_ID == 3 || x.Area_ID == 4 || x.Area_ID == 5).ToList(), allCoEs = db.CoEs.Where(x => x.CoE_ID > 10 && x.CoE_ID < 20 && x.CoE_ID != 14).ToList(), allFootnotes =db.Footnotes.ToList(), Fiscal_Year = fiscalYear.Value, }; return View(indexViewModel); }