public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion,
            string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
        {
            ValidatePasswordEventArgs args =
           new ValidatePasswordEventArgs(username, password, true);
            OnValidatingPassword(args);

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

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

            MembershipUser user = GetUser(username, true);

            if (user == null)
            {
                var userObj = new AppUser();
                userObj.Username = username;
                userObj.Password = GetMD5Hash(password);
                userObj.Email = email;
                userObj.DateCreated = DateTime.UtcNow;
                userObj.LastActivityDate = DateTime.UtcNow;

                entities.AppUsers.Add(userObj);
                entities.SaveChanges();

                status = MembershipCreateStatus.Success;

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

            return null;
        }
        public override MembershipUser GetUser(string username, bool userIsOnline)
        {
            AppUser userRep = new AppUser() { DateCreated = DateTime.UtcNow };

            var user = entities.AppUsers.Where(x => x.Username == username).FirstOrDefault();

            if (user != null)
            {
                MembershipUser memUser = new MembershipUser("CustomMembershipProvider", username, user.Id, user.Email, string.Empty, string.Empty,
                                        true, false, user.DateCreated, DateTime.MinValue, user.LastActivityDate ?? DateTime.MinValue, DateTime.UtcNow, DateTime.UtcNow);
                return memUser;
            }

            return null;
        }