Beispiel #1
0
        public async Task <RegistrationResult> Register(SellerRegisterDto sellerDto)
        {
            if (await IsEmailExistAsync(sellerDto.Email))
            {
                return(RegistrationResult.EmailAlreadyExist);
            }

            var account = new Account
            {
                Email        = sellerDto.Email,
                PasswordHash = _hashingService.CreateMD5(sellerDto.Password)
            };

            await _context.Accounts.AddAsync(account);

            await _context.SaveChangesAsync();

            var secretKey = new SecretKey
            {
                Value     = "SellerSecretKey" + account.Id,
                AccountId = account.Id
            };

            var seller = new Seller
            {
                AccountId = account.Id,
                PublicKey = "SellerPublicKey" + account.Id,
            };

            await _context.SecretKeys.AddAsync(secretKey);

            await _context.Sellers.AddAsync(seller);

            await _context.SaveChangesAsync();

            return(RegistrationResult.Success);
        }
Beispiel #2
0
        public async Task <RegistrationResult> Register(PlatformRegisterDto platformDto)
        {
            if (await IsEmailExistAsync(platformDto.Email))
            {
                return(RegistrationResult.EmailAlreadyExist);
            }

            var account = new Account
            {
                Email        = platformDto.Email,
                PasswordHash = _hashingService.CreateMD5(platformDto.Password)
            };

            await _context.Accounts.AddAsync(account);

            await _context.SaveChangesAsync();

            var secretKey = new SecretKey
            {
                Value     = "PlatformSecretKey" + account.Id,
                AccountId = account.Id
            };

            var platform = new Platform
            {
                AccountId = account.Id,
                PublicKey = "PlatformPublicKey" + account.Id,
            };

            await _context.SecretKeys.AddAsync(secretKey);

            await _context.Platforms.AddAsync(platform);

            await _context.SaveChangesAsync();

            return(RegistrationResult.Success);
        }