public static List<RouteElement> RoutesListByRole(string role) { var list = new List<RouteElement>(); using (var db = new DataModel()) { var queryRoutes = db.webpages_Roles.Where(x => x.RoleName.Equals(role, StringComparison.InvariantCultureIgnoreCase)).SelectMany(x => x.routes).ToList(); foreach (var item in queryRoutes) { list.Add(new RouteElement { Action = item.Action, Controller = item.Controller }); } } return list; }
// // GET: /Home/ // [Authorize(Roles = "Admin")] public ActionResult Index() { if (!WebSecurity.IsAuthenticated) { Response.Redirect("~/account/login"); } var userId = WebSecurity.CurrentUserId; using (var db = new DataModel()) { var userInfo = db.Users.FirstOrDefault(x => x.ID == userId); ViewBag.displayName = userInfo; } return View(); }