Example #1
0
        public IEnumerable<Action> BuildActions(Role role)
        {
            var actions = new List<Action>();

            actions.Add(new Action("Analytics", "Stats/Index"));
            return actions;
        }
Example #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;
        }
        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;
        }
Example #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;
        }
Example #5
0
 public ActionResult Edit(int id, Role role)
 {
     if (ModelState.IsValid && Storage.EditRole(id, role))
     {
         return RedirectToAction("Index");
     }
     else
     {
         return View(role);
     }
 }
Example #6
0
 public ActionResult Create(Role role)
 {
     if (ModelState.IsValid && Storage.CreateRole(role))
     {
         return RedirectToAction("Index");
     }
     else
     {
         return View(role);
     }
 }
Example #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;
        }
Example #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;
        }
Example #9
0
 public bool CreateRole(Role role)
 {
     try
     {
         db.Roles.InsertOnSubmit(role);
         db.SubmitChanges();
         return true;
     }
     catch
     {
         return false;
     }
 }
Example #10
0
        public override void CreateRole(string roleName)
        {
            try
            {
                Role role = new Role { Name = roleName };

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

            }
        }
Example #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());
        }
Example #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();
        }
Example #13
0
 public IEnumerable<IUDICO.Common.Models.Action> BuildActions(Role role)
 {
     return Enumerable.Empty<IUDICO.Common.Models.Action>();
 }
Example #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));
        }
Example #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();
        }
Example #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;
     }
 }
Example #17
0
 public IEnumerable<Action> BuildActions(Role role)
 {
     return new List<Action>();
 }
Example #18
0
 partial void InsertRole(Role instance);
 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;
 }
Example #20
0
 partial void UpdateRole(Role instance);
Example #21
0
 public IEnumerable<User> GetUsersInRole(Role role)
 {
     var db = GetDbContext();
     
     return db.UserRoles.Where(ur => ur.RoleRef == (int) role).Select(ur => ur.User);
 }
Example #22
0
 partial void DeleteRole(Role instance);
Example #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");
        }
Example #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");
 }