//Отображение экологических советов public ActionResult Councils() { if (Session["Role"] != null && Session["Role"].ToString() == "Secretary") { //Скрывать ли ссылку создания совета или нет if (db.Councils.ToList().Count == db.EcologicalProblems.ToList().Count) ViewBag.showCreateLink = false; else ViewBag.showCreateLink = true; CouncilsProblems list = new CouncilsProblems(); list.listCouncils = db.Councils.ToList(); list.listProblems = (from problem in db.EcologicalProblems select problem).ToList(); return View(list); } else { return RedirectToAction("Http403", "Error"); } }
public ActionResult GetCrucialProblems(string daysRange) { CouncilsProblems list = new CouncilsProblems(); list.listCouncils = db.Councils.ToList(); int days; if (int.TryParse(daysRange, out days)) { try { list.listProblems = db.Database.SqlQuery<EcologicalProblem>("GetEcologicalProblems @days_range", new SqlParameter("days_range", days)).ToList(); int l = list.listProblems.Count; } catch { list.listProblems = (from problem in db.EcologicalProblems select problem).ToList(); } } else { list.listProblems = (from problem in db.EcologicalProblems select problem).ToList(); } //Скрывать ли ссылку создания совета или нет if (db.Councils.ToList().Count == db.EcologicalProblems.ToList().Count) ViewBag.showCreateLink = false; else ViewBag.showCreateLink = true; return View("Councils", list); }