// GET: VolunteerCenters public ActionResult Index(int?page, string searchString, string currentFilter) { var results = from x in db.VolunteerCenter select x; int pagesize = 9, pageindex = 1; VCList temp = new VCList(); if (searchString != null) { page = 1; } else { searchString = currentFilter; } // Showing data based on the search query string and the star rating selected from the dropdown. ViewData["CurrentFilter"] = searchString; if (!String.IsNullOrEmpty(searchString)) { results = results.Where(s => s.Name.Contains(searchString) || s.Address.Contains(searchString) || s.Suburb.Contains(searchString) || s.State.Contains(searchString) || s.Business_Category.Contains(searchString) || s.LGA.Contains(searchString) || s.Region.Contains(searchString) || s.Business_Category.Contains(searchString) || s.Postcode.ToString().Contains(searchString)); } else { results = results.Where(x => x.State == "VIC"); } pageindex = page.HasValue ? Convert.ToInt32(page) : 1; var list = results.ToList(); temp.VCs = list.ToPagedList(pageindex, pagesize); return(View(temp)); }
// GET: VolunteerCenters public ActionResult Index(int?page, string searchString, string currentFilter, string Category, string currentCategory) { decimal category; if (!String.IsNullOrEmpty(Category)) { category = decimal.Parse(Category); } else if (!String.IsNullOrEmpty(currentCategory)) { category = decimal.Parse(currentCategory); } else { category = -1; } var results = from x in db.VolunteerCenters select x; int pagesize = 9, pageindex = 1; VCList temp = new VCList(); if (searchString != null || Category != null) { page = 1; } else { Category = currentCategory; searchString = currentFilter; } // Showing data based on the search query string and the star rating selected from the dropdown. ViewData["CurrentFilter"] = searchString; ViewData["currentCategory"] = Category; if (!String.IsNullOrEmpty(searchString) && category != -1) { switch (category) { case 1: results = results.Where(s => (s.Name.Contains(searchString) || s.Suburb.Contains(searchString)) && s.Business_Category.Contains("Disability") ); break; case 2: results = results.Where(s => (s.Name.Contains(searchString) || s.Suburb.Contains(searchString)) && s.Business_Category.Contains("Recreation Group") ); break; case 3: results = results.Where(s => (s.Name.Contains(searchString) || s.Suburb.Contains(searchString)) && s.Business_Category.Contains("State body") ); break; case 4: results = results.Where(s => (s.Name.Contains(searchString) || s.Suburb.Contains(searchString)) && s.Business_Category.Contains("Volunteering") ); break; case 5: results = results.Where(s => (s.Name.Contains(searchString) || s.Suburb.Contains(searchString)) && s.Business_Category.Contains("Walking Club/Group") ); break; } } else if (!String.IsNullOrEmpty(searchString) && category == -1) { results = results.Where(s => s.Name.Contains(searchString) || s.Suburb.Contains(searchString)); } else if (String.IsNullOrEmpty(searchString) && category != -1) { switch (category) { case 1: results = results.Where(s => s.Business_Category.Contains("Disability")); break; case 2: results = results.Where(s => s.Business_Category.Contains("Recreation Group")); break; case 3: results = results.Where(s => s.Business_Category.Contains("State body")); break; case 4: results = results.Where(s => s.Business_Category.Contains("Volunteering")); break; case 5: results = results.Where(s => s.Business_Category.Contains("Walking Club/Group")); break; } } else { results = from x in db.VolunteerCenters select x; } pageindex = page.HasValue ? Convert.ToInt32(page) : 1; var list = results.ToList(); temp.VCs = list.ToPagedList(pageindex, pagesize); List <SelectListItem> Category_list = new List <SelectListItem>(); Category_list.Add(new SelectListItem() { Text = "All Categories", Value = "-1" }); Category_list.Add(new SelectListItem() { Text = "Disability", Value = "1" }); Category_list.Add(new SelectListItem() { Text = "Recreation Group", Value = "2" }); Category_list.Add(new SelectListItem() { Text = "State body", Value = "3" }); Category_list.Add(new SelectListItem() { Text = "Volunteering", Value = "4" }); Category_list.Add(new SelectListItem() { Text = "Walking Club/Group", Value = "5" }); this.ViewBag.Category = new SelectList(Category_list, "Value", "Text", currentCategory); return(View(temp)); }
public IEnumerable <VCList> GetSer() { List <VCList> obj = new List <VCList>(); try { VCList o = new VCList(); VCList o1 = new VCList(); VCList o2 = new VCList(); VCList o3 = new VCList(); VCList o4 = new VCList(); VCList o5 = new VCList(); VCList o6 = new VCList(); VCList o7 = new VCList(); List <VC> list_vc = gbc_con.Db_vc.Where(p => p.FDNAME == "SALE").ToList(); o.FDNAME = "SALE"; o.vcli = list_vc; obj.Add(o); list_vc = gbc_con.Db_vc.Where(p => p.FDNAME == "WSAL").ToList(); o1.FDNAME = "WSAL"; o1.vcli = list_vc; obj.Add(o1); list_vc = gbc_con.Db_vc.Where(p => p.FDNAME == "ORDS").ToList(); o2.FDNAME = "ORDS"; o2.vcli = list_vc; obj.Add(o2); list_vc = gbc_con.Db_vc.Where(p => p.FDNAME == "ORDR").ToList(); o3.FDNAME = "ORDR"; o3.vcli = list_vc; obj.Add(o3); list_vc = gbc_con.Db_vc.Where(p => p.FDNAME == "MNRC").ToList(); o4.FDNAME = "MNRC"; o4.vcli = list_vc; obj.Add(o4); list_vc = gbc_con.Db_vc.Where(p => p.FDNAME == "MNPY").ToList(); o5.FDNAME = "MNPY"; o5.vcli = list_vc; obj.Add(o5); list_vc = gbc_con.Db_vc.Where(p => p.FDNAME == "QTTN").ToList(); o6.FDNAME = "QTTN"; o6.vcli = list_vc; obj.Add(o6); list_vc = gbc_con.Db_vc.Where(p => p.FDNAME == "QTNW").ToList(); o7.FDNAME = "QTNW"; o7.vcli = list_vc; obj.Add(o7); return(obj); } catch { return(obj); } }