public override bool ValidateUser(string username, string password)
 {
     bool isValid = false;
     using (AccountRepository repository = new AccountRepository())
     {
         try
         {
             IUser user = repository.GetUser(username);
             if (user != null && Crypto.VerifyHashedPassword(user.Password, password))
             {
                 isValid = true;
             }
         }
         catch
         {
             isValid = false;
         }
     }
     return isValid;
 }
 public override string[] GetRolesForUser(string username)
 {
     string[] roles = new string[] { };
     using (AccountRepository repository = new AccountRepository())
     {
         try
         {
             IUser user = repository.GetUser(username);
             if (user != null)
             {
                 roles = repository.GetRolesForUser(username);
             }
         }
         catch
         {
             roles = new string[] { };
         }
     }
     return roles;
 }
 public override MembershipUser GetUser(string username, bool userIsOnline)
 {
     try
     {
         using(AccountRepository repository = new AccountRepository())
         {
             var user = repository.GetUser(username);
             if (user != null)
             {
                 MembershipUser memberUser = new MembershipUser("MyMembershipProvider", user.Nick, null, user.Email, null, null,
                     false, false, user.CreateDateTime, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue);
                 return memberUser;
             }
         }
     }
     catch
     {
         return null;
     }
     return null;
 }
 public MembershipUser CreateUser(string username, string password, string email)
 {
     MembershipUser membershipUser = GetUser(username, false);
     if (membershipUser == null)
     {
         try
         {
             using(AccountRepository repository = new AccountRepository())
             {
                 repository.AddUserWithRole(username, email, Crypto.HashPassword(password));
                 membershipUser = GetUser(username, false);
                 return membershipUser;
             }
         }
         catch
         {
             return null;
         }
     }
     return null;
 }
 public override bool IsUserInRole(string username, string roleName)
 {
     bool result = false;
     using(AccountRepository repository = new AccountRepository())
     {
         try
         {
             IUser user = repository.GetUser(username);
             if (user != null)
             {
                 string[] roles = GetRolesForUser(username);
                 result = roles.Contains(roleName);
             }
         }
         catch
         {
             result = false;
         }
     }
     return result;
 }