public async Task GrantFullAccessToAccount(Character character, BankAccount bankAccount) { using var dbContext = _dbContextFactory.CreateDbContext(); var access = new BankAccountCharacterAccess { BankAccountId = bankAccount.Id, CharacterId = character.Id, CanSeeTransactions = true, CanWithdraw = true }; dbContext.BankAccountCharacterAccesses.Update(access); await dbContext.SaveChangesAsync(); }
public async Task <BankAccount> CreateNewAccountForCharacter(Character owner) { using var dbContext = _dbContextFactory.CreateDbContext(); var bankAcc = new BankAccount(); dbContext.BankAccounts.Add(bankAcc); var bankAccAccess = new BankAccountCharacterAccess { BankAccountId = bankAcc.Id, CharacterId = owner.Id, CanWithdraw = true, CanSeeTransactions = true, CanManagePermissions = true }; dbContext.BankAccountCharacterAccesses.Add(bankAccAccess); await dbContext.SaveChangesAsync(); return(bankAcc); }