public IActionResult ManageAlien(string id) { model = new AlienModel(HttpContext.Session.GetString("dbusername"), HttpContext.Session.GetString("dbpassword")); ViewBag.Alien = model.GetRegdAlien(id); if (ViewBag.Alien.Rows.Count > 0) { ViewBag.Type = "regd"; } else { ViewBag.Alien = model.GetUnregdAlien(id); if (ViewBag.Alien.Rows.Count > 0) { ViewBag.Type = "unregd"; } else { ViewBag.Type = null; } } ViewBag.DangerDegrees = model.GetDangerDegrees(); ViewBag.Races = model.GetRaces(); ViewBag.Planets = model.GetPlanets(); ViewBag.Race = model.GetRace(ViewBag.Alien.Rows[0]["race"].ToString()); return(View()); }
public IActionResult Index(string search, string filter) { if (HttpContext.Session.GetString("dbusername") == null || HttpContext.Session.GetString("dbusername") == "guest") { return(RedirectToAction("Index", "Home")); } model = new AlienModel(HttpContext.Session.GetString("dbusername"), HttpContext.Session.GetString("dbpassword")); search = search ?? ""; if (search == "" && filter == null) { ViewBag.RegdAliens = model.GetRegdAliens(); ViewBag.UnregdAliens = model.GetUnregdAliens(); } else { ViewBag.Search = search; ViewBag.Filter = filter; if (filter == "regd") { ViewBag.RegdAliens = model.GetRegdSearch("%" + search + "%"); } else if (filter == "unregd") { ViewBag.UnregdAliens = model.GetUnregdSearch("%" + search + "%"); } else if (filter == "all") { ViewBag.RegdAliens = model.GetRegdSearch("%" + search + "%"); ViewBag.UnregdAliens = model.GetUnregdSearch("%" + search + "%"); } } ViewBag.DangerDegrees = model.GetDangerDegrees(); ViewBag.Races = model.GetRaces(); ViewBag.Planets = model.GetPlanets(); return(View()); }