Esempio n. 1
0
 /// <summary>
 /// Adds user to role
 /// </summary>
 /// <param name="role"></param>
 /// <param name="user"></param>
 public void AddUserToRole(Role role, User user)
 {
     if (!role.Users.Contains(user))
     {
         role.Users.Add(user);
         AddRoleToUser(user, role);
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Adds role to user
 /// </summary>
 /// <param name="user"></param>
 /// <param name="role"></param>
 public virtual void AddRoleToUser(User user, Role role)
 {
     if (!user.Roles.Contains(role))
     {
         user.Roles.Add(role);
         AddUserToRole(role, user);
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Creates role which name is "rolename"
 /// </summary>
 /// <param name="roleName"></param>
 public void CreateRole(string roleName)
 {
     if (RoleExists(roleName)) return;
     var role = new Role { RoleName = roleName };
     _rolesContext.Add(role);
 }