public async Task <bool> CreateAccountAsync(Services.Models.Customer customerModel) { try { Entities.Customer newCustomer = _mapper.Map <Entities.Customer>(customerModel); newCustomer.Id = Guid.NewGuid(); newCustomer.Active = false; _accountContext.Customers.Add(newCustomer); var account = new Entities.Account() { Id = Guid.NewGuid(), CustomerId = newCustomer.Id, Opendate = DateTime.Today, Balance = 100000, }; _accountContext.Accounts.Add(account); await _accountContext.SaveChangesAsync(); return(true); } catch (Exception e) { throw new CreateAccountFailed($"Account creation for { customerModel.Email } failed"); } }
public async Task <bool> CreateAccountAsync(Services.Models.Customer customerModel) { Entities.Customer newCustomer = _mapper.Map <Entities.Customer>(customerModel); newCustomer.Id = Guid.NewGuid(); newCustomer.Active = false; _accountContext.Customers.Add(newCustomer); var account = new Entities.Account() { Id = Guid.NewGuid(), CustomerId = newCustomer.Id, Opendate = DateTime.Today, Balance = 100000, }; _accountContext.Accounts.Add(account); await _accountContext.SaveChangesAsync(); return(true); }