Пример #1
0
        public IEnumerable<Action> BuildActions(Role role)
        {
            var actions = new List<Action>();

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

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

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