public virtual async Task <AccountResult <string> > RegisterAsync(Models.RegisterInfo register)
        {
            if (register.Password != register.ConfirmPassword)
            {
                return(AccountResult.Unsuccessful(data: "", "两次密码不一致"));
            }

            var user = await GetUserFromEmailAsync(register.Email);

            if (user != null)
            {
                return(AccountResult.Unsuccessful(data: "", "已经被使用的邮箱"));
            }

            user = new ScreamBackend.DB.Tables.User
            {
                Email           = register.Email,
                NormalizedEmail = Formator.EmailNormaliz(register.Email),
                Username        = Formator.SplitUsernameFromEmail(register.Email),
                PasswordHash    = register.Password
            };
            user.NormalizedUsername = Formator.UsernameNormaliz(user.Username);

            _db.Users.Add(user);
            int effects = await _db.SaveChangesAsync();

            if (effects == 1)
            {
                return(AccountResult.Successful(user.Email));
            }
            throw new Exception("Register fail");
        }
        public virtual async Task <AbstractUser> GetUserAsync(string account)
        {
            if (string.IsNullOrWhiteSpace(account))
            {
                return(null);
            }

            string normalizedEmail    = Formator.EmailNormaliz(account);
            string normalizedUsername = Formator.UsernameNormaliz(account);

            var user = await _db.Users.AsNoTracking()
                       .Where(u => u.NormalizedUsername == normalizedUsername ||
                              u.NormalizedEmail == normalizedEmail)
                       .SingleOrDefaultAsync();

            return(ReturnUser(user));
        }