public override void OnAuthorization(AuthorizationContext filterContext) { //ToTest //int roleID = Convert.ToInt32(HttpContext.Current.Session["RoleID"]); int roleID = 1; UserService service = new UserService(); IEnumerable<UserBrowseViewModel> modules = service.GetUserBrowse(roleID); foreach (UserBrowseViewModel module in modules) { filterContext.SetViewData(module.Code, module.Name); } }
public override void OnAuthorization(AuthorizationContext filterContext) { //ToTest //int roleID = Convert.ToInt32(HttpContext.Current.Session["RoleID"]); int roleID = 1; using (DBEntity db = new DBEntity()) { IEnumerable<UserBrowseViewModel> modules = db.GetUserBrowse(roleID).AsEnumerable(); foreach (UserBrowseViewModel module in modules) { filterContext.SetViewData(module.Code, module.Name); } } }
public override void OnAuthorization(AuthorizationContext filterContext) { //ToTest //int roleID = Convert.ToInt32(HttpContext.Current.Session["RoleID"]); int roleID = 1; string controller = filterContext.GetController(); ModuleService moduleService = new ModuleService(); int controllerID = moduleService.GetModuleIdByName(controller); UserService userService = new UserService(); IEnumerable<string> actions = userService.GetUserOperation(roleID, controllerID); foreach (string action in actions) { filterContext.SetViewData(action, true); } }
public override void OnAuthorization(AuthorizationContext filterContext) { using (DBEntity db = new DBEntity()) { //ToTest //int roleID = Convert.ToInt32(HttpContext.Current.Session["RoleID"]); int roleID = 1; string controller = filterContext.GetController(); int controllerID = db.Module.GetEntityField(m => m.Controller == controller, m => m.ID); IEnumerable<string> actions = db.GetUserOperation(roleID, controllerID); foreach (string action in actions) { filterContext.SetViewData(action, true); } } }