public virtual Task <ApplicationUser> FindByRegistrationNumberAsync(string registrationNumber)
        {
            IUserCustomStore <ApplicationUser> userCustomStore = this.Store as IUserCustomStore <ApplicationUser>;

            if (registrationNumber == null)
            {
                throw new ArgumentNullException("registrationNumber");
            }
            return(userCustomStore.FindByRegistrationNumberAsync(registrationNumber));
        }
        public virtual Task <ApplicationUser> FindByProfileNameAsync(string profileName)
        {
            IUserCustomStore <ApplicationUser> userCustomStore = this.Store as IUserCustomStore <ApplicationUser>;

            if (profileName == null)
            {
                throw new ArgumentNullException("profileName");
            }
            return(userCustomStore.FindByProfileNameAsync(profileName));
        }
        public virtual Task <ApplicationUser> FindByPhoneNumberUserManagerAsync(string phoneNumber)
        {
            IUserCustomStore <ApplicationUser> userCustomStore = this.Store as IUserCustomStore <ApplicationUser>;

            if (phoneNumber == null)
            {
                throw new ArgumentNullException("phoneNumber");
            }
            return(userCustomStore.FindByPhoneNumberAsync(phoneNumber));
        }
        public virtual Task <ApplicationUser> FindByEmailUserManagerAsync(string phoneNumber)
        {
            IUserCustomStore <ApplicationUser> userCustomStore = Store as IUserCustomStore <ApplicationUser>;

            //if (phoneNumber == null)
            //{
            //    return new Task<ApplicationUser>();
            //    //throw new ArgumentNullException();
            //}
            return(userCustomStore?.FindByEmailAddressAsync(phoneNumber));
        }
        public ApplicationUserManager(IUserCustomStore <TUser> store)
            : base(store)
        {
            UserValidator = new ApplicationUserValidator <TUser>(this)
            {
                //RequireUniqueEmail = true,
            };

            this.EmailService = new EmailService();
            //var provider = new DpapiDataProtectionProvider("AppName");
            //this.UserTokenProvider = new DataProtectorTokenProvider<TUser, string>(provider.Create("ASP.NET Identity")); ; //new DataProtectorTokenProvider<ApplicationUser, long>(provider.Create("PasswordReset"));
        }