Example #1
0
 public Task AddToRoleAsync(ApplicationUser user, string roleName)
 {
     if (user != null)
     {
         return(Task.Factory.StartNew(() =>
         {
             AccountRoleController.NewUserRole(user.Id, roleName);
         }));
     }
     else
     {
         throw new ArgumentNullException("user");
     }
 }
Example #2
0
 public Task CreateAsync(ApplicationUser user)
 {
     if (user != null)
     {
         return(Task.Factory.StartNew(() =>
         {
             user.Id = Guid.NewGuid().ToString();
             user.Status = Models.EnumAccountStatus.Active;
             AccountRoleController.NewUserRole(user.Id, "Student");
             AccountController.NewUser(user);
         }));
     }
     throw new ArgumentNullException("user");
 }
Example #3
0
 public Task <IList <string> > GetRolesAsync(ApplicationUser user)
 {
     if (user != null)
     {
         return(Task.Factory.StartNew(() =>
         {
             IList <string> roles = AccountRoleController.GetUserRoles(user.Id);
             return roles;
         }));
     }
     else
     {
         throw new ArgumentNullException("user");
     }
 }
Example #4
0
        public Task <bool> IsInRoleAsync(ApplicationUser user, string roleName)
        {
            if (user != null)
            {
                return(Task.Factory.StartNew(() =>
                {
                    IList <string> roles = AccountRoleController.GetUserRoles(user.Id);
                    foreach (string role in roles)
                    {
                        if (role.ToUpper() == roleName.ToUpper())
                        {
                            return true;
                        }
                    }

                    return false;
                }));
            }
            else
            {
                throw new ArgumentNullException("user");
            }
        }