Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Register(PlatformRegisterDto platformDto)
        {
            var result = await _platformService.Register(platformDto);

            return(Ok(result));
        }