public ActionResult Index() { if (User.Identity.IsAuthenticated) { UserManager manager = new UserManager(); List<Skill> returnList = new List<Skill>(); try { foreach (Skill s in db.Skills.ToList()) { if (s.User.Id.Equals(manager.getIdFromUsername(User.Identity.Name))) { returnList.Add(s); } } } catch (NullReferenceException e) { } return View(returnList); } return RedirectToAction("NotLoggedIn", "Home"); }
public ActionResult Index(string category) { Category cat = db.Categories.FirstOrDefault(c => c.Name == category); if (cat == null) {return Index();} // run the default index if the given category doesn't exist. if (User.Identity.IsAuthenticated) { UserManager manager = new UserManager(); List<Skill> returnList = new List<Skill>(); try { if (true) { foreach (Skill s in db.Skills.ToList()) { if (s.User.Id.Equals(manager.getIdFromUsername(User.Identity.Name)) && hasCat(s.Categories, cat)) { returnList.Add(s); } } } } catch (NullReferenceException e) { } return View(returnList); } return RedirectToAction("NotLoggedIn", "Home"); }
public ActionResult Index() { if (User.Identity.IsAuthenticated) { UserManager manager = new UserManager(); List<Goal> returnList = new List<Goal>(); try { foreach (Goal g in db.Goals.ToList()) { if (g.User.Id.Equals(manager.getIdFromUsername(User.Identity.Name))) { returnList.Add(g); } } } catch (NullReferenceException e) { } //ViewBag.Cats = db.Categories.ToList(); return View(returnList); } return RedirectToAction("NotLoggedIn", "Home"); }