public override MembershipUser GetUser(string username, bool userIsOnline)
 {
     var usersContext = new UsersContext();
     var user = usersContext.GetUser(username);
     if (user != null)
     {
         var memUser = new MembershipUser("CustomMembershipProvider", username, user.UserID, user.UserEmailAddress,
                                                     string.Empty, string.Empty,
                                                     true, false, DateTime.MinValue,
                                                     DateTime.MinValue,
                                                     DateTime.MinValue,
                                                     DateTime.Now, DateTime.Now);
         return memUser;
     }
     return null;
 }
        public override bool ValidateUser(string username, string password)
        {
            var md5Hash = GetMd5Hash(password);

            using (var usersContext = new UsersContext())
            {
                var requiredUser = usersContext.GetUser(username, md5Hash);
                return requiredUser != null;
            }
        }
        public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
        {
            var args = new ValidatePasswordEventArgs(username, password, true);
            OnValidatingPassword(args);

            if (args.Cancel)
            {
                status = MembershipCreateStatus.InvalidPassword;
                return null;
            }

            if (RequiresUniqueEmail && GetUserNameByEmail(email) != string.Empty)
            {
                status = MembershipCreateStatus.DuplicateEmail;
                return null;
            }

            var user = GetUser(username, true);

            if (user == null)
            {
                var userObj = new User { UserName = username, Password = GetMd5Hash(password), UserEmailAddress = email };

                using (var usersContext = new UsersContext())
                {
                    usersContext.AddUser(userObj);
                }

                status = MembershipCreateStatus.Success;

                return GetUser(username, true);
            }
            status = MembershipCreateStatus.DuplicateUserName;

            return null;
        }