コード例 #1
0
        public async Task CreateAccount(CreateAccountViewModel vm)
        {
            var(password, salt) = _passwordProtectionService.Encrypt(vm.PlainTextPassword);

            if (!vm.IsAdmin)
            {
                var customer = new Customer
                {
                    FullName    = vm.FullName,
                    PhoneNumber = vm.PhoneNumber,
                    Account     = new Account {
                        Salt = salt, AccountType = AccountTypes.Standard, Password = password, Username = vm.Username
                    }
                };
                await _customerRepository.AddAysnc(customer);

                await _customerRepository.SaveAsync();

                return;
            }

            var account = new Account
            {
                Username = vm.Username, AccountType = AccountTypes.Admin, Password = password, Salt = salt
            };

            await _accountRepository.AddAysnc(account);

            await _accountRepository.SaveAsync();
        }