Пример #1
0
 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());
 }