Ejemplo n.º 1
0
        public IEnumerable<Action> BuildActions(Role role)
        {
            var actions = new List<Action>();

            actions.Add(new Action("Analytics", "Stats/Index"));
            return actions;
        }
Ejemplo n.º 2
0
        public IEnumerable<Action> BuildActions(Role role)
        {
            var actions = new List<Action>();

            actions.Add(new Action(IUDICO.Statistics.Localization.getMessage("GetStats"), "Stats/Index"));
            actions.Add(new Action(IUDICO.Statistics.Localization.getMessage("QualityTest"), "QualityTest/SelectCurriculum"));
            return actions;
        }
Ejemplo n.º 3
0
        public IEnumerable<Action> BuildActions(Role role)
        {
            var actions = new List<Action>();

            actions.Add(new Action(IUDICO.CourseManagement.Localization.getMessage("GetCourses"), "Course/Index"));
            actions.Add(new Action(IUDICO.CourseManagement.Localization.getMessage("CreateCourse"), "Course/Create"));
            actions.Add(new Action(IUDICO.CourseManagement.Localization.getMessage("EditCourse"), "Course/Index"));

            return actions;
        }
Ejemplo n.º 4
0
        public IEnumerable<IUDICO.Common.Models.Action> BuildActions(Role role)
        {
            var actions = new List<Action>();

            // do not add actions for testing service
            //actions.Add(new Action("Import Testings", "Package/Index"));
            //actions.Add(new Action("Available Testings", "Training/Index"));

            return actions;
        }
Ejemplo n.º 5
0
 public ActionResult Edit(int id, Role role)
 {
     if (ModelState.IsValid && Storage.EditRole(id, role))
     {
         return RedirectToAction("Index");
     }
     else
     {
         return View(role);
     }
 }
Ejemplo n.º 6
0
 public ActionResult Create(Role role)
 {
     if (ModelState.IsValid && Storage.CreateRole(role))
     {
         return RedirectToAction("Index");
     }
     else
     {
         return View(role);
     }
 }
Ejemplo n.º 7
0
        public IEnumerable<Action> BuildActions(Role role)
        {
            var actions = new List<Action>
                              {
                                  new Action(IUDICO.UserManagement.Localization.getMessage("GetUsers"), "User/Index"),
                                  new Action(IUDICO.UserManagement.Localization.getMessage("GetGroups"), "Group/Index"),
                                  new Action(IUDICO.UserManagement.Localization.getMessage("Register"), "Account/Register"),
                                  new Action(IUDICO.UserManagement.Localization.getMessage("Login"), "Account/Login")
                              };

            return actions;
        }
Ejemplo n.º 8
0
        public IEnumerable<Action> BuildActions(Role role)
        {
            var actions = new List<Action>
                              {
                                  new Action(Localization.getMessage("GetUsers"), "User/Index"),
                                  new Action(Localization.getMessage("GetGroups"), "Group/Index"),
                                  new Action(Localization.getMessage("Register"), "Account/Register"),
                                  new Action(Localization.getMessage("ForgotPassword"), "Account/Forgot"),
                                  new Action(Localization.getMessage("Login"), "Account/Login"),
                              };

            return actions;
        }
Ejemplo n.º 9
0
 public bool CreateRole(Role role)
 {
     try
     {
         db.Roles.InsertOnSubmit(role);
         db.SubmitChanges();
         return true;
     }
     catch
     {
         return false;
     }
 }
Ejemplo n.º 10
0
        public override void CreateRole(string roleName)
        {
            try
            {
                Role role = new Role { Name = roleName };

                db.Roles.InsertOnSubmit(role);
                db.SubmitChanges();
            }
            catch (Exception)
            {

            }
        }
Ejemplo n.º 11
0
        protected bool IsAllowed(Action fullAction, Role role)
        {
            var parts = fullAction.Link.Split('/');

            var controller = _Container.Resolve<IController>(parts[0] + "controller");
            var action = controller.GetType().GetMethods().Where(m => m.Name == parts[1] && !IsPost(m) && m.GetParameters().Length == 0).FirstOrDefault();

            var attribute = Attribute.GetCustomAttribute(action, typeof(AllowAttribute), false) as AllowAttribute;

            return attribute == null || Roles.Provider.IsUserInRole(HttpContext.Current.User.Identity.Name, attribute.Role.ToString());
        }
Ejemplo n.º 12
0
        public void AddUserToRole(Role role, User user)
        {
            var db = this.GetDbContext();

            var userRole = new UserRole { RoleRef = (int)role, UserRef = user.Id };

            db.UserRoles.InsertOnSubmit(userRole);
            db.SubmitChanges();
        }
Ejemplo n.º 13
0
 public IEnumerable<IUDICO.Common.Models.Action> BuildActions(Role role)
 {
     return Enumerable.Empty<IUDICO.Common.Models.Action>();
 }
Ejemplo n.º 14
0
        public IEnumerable<User> GetUsersInRole(Role role)
        {
            var db = this.GetDbContext();
            var userIds = db.UserRoles.Where(ur => ur.RoleRef == (int)role).Select(ur => ur.UserRef);

            return db.Users.Where(u => userIds.Contains(u.Id));
        }
Ejemplo n.º 15
0
        public void RemoveUserFromRole(Role role, User user)
        {
            var db = this.GetDbContext();

            var userRole = db.UserRoles.Single(g => g.RoleRef == (int)role && g.UserRef == user.Id);

            db.UserRoles.DeleteOnSubmit(userRole);
            db.SubmitChanges();
        }
Ejemplo n.º 16
0
 public bool EditRole(int id, Role role)
 {
     try
     {
         Role oldRole = GetRole(id);
         oldRole.Name = role.Name;
         db.SubmitChanges();
         return true;
     }
     catch
     {
         return false;
     }
 }
Ejemplo n.º 17
0
 public IEnumerable<Action> BuildActions(Role role)
 {
     return new List<Action>();
 }
Ejemplo n.º 18
0
 partial void InsertRole(Role instance);
Ejemplo n.º 19
0
 public IEnumerable<Action> BuildActions(Role role)
 {
     List<Action> actions = new List<Action>();
     actions.Add(new Action(IUDICO.CurriculumManagement.Localization.getMessage("CurriculumManagement"), "Curriculum/Index"));
     return actions;
 }
Ejemplo n.º 20
0
 partial void UpdateRole(Role instance);
Ejemplo n.º 21
0
 public IEnumerable<User> GetUsersInRole(Role role)
 {
     var db = GetDbContext();
     
     return db.UserRoles.Where(ur => ur.RoleRef == (int) role).Select(ur => ur.User);
 }
Ejemplo n.º 22
0
 partial void DeleteRole(Role instance);
Ejemplo n.º 23
0
        public void AddUserToRole(Role role, User user)
        {
            this.storage.AddUserToRole(role, user);

            this.cacheProvider.Invalidate(
                "role-" + role, "user-id-" + user.Id, "user-name-" + user.Username, "users", "roles");
        }
Ejemplo n.º 24
0
 public IEnumerable<User> GetUsersInRole(Role role)
 {
     return this.cacheProvider.Get(
         "users-role-" + role,
         this.lockObject,
         () => this.storage.GetUsersInRole(role).ToList(),
         DateTime.Now,
         "users");
 }