public async Task <bool> RemoveAsync(int id, VirtualBankDbContext dbContext = null) { var isDeleted = false; if (dbContext != null) { var address = await dbContext.Addresses.FindAsync(id); if (address != null) { address.Disabled = true; await SaveAsync(dbContext); isDeleted = true; } } else { var address = await _dbContext.Addresses.FindAsync(id); if (address != null) { address.Disabled = true; await SaveAsync(); isDeleted = true; } } return(isDeleted); }
public async Task <Address> UpdateAsync(Address address, VirtualBankDbContext dbContext = null) { if (dbContext != null) { var existingAddress = await dbContext.Addresses .FirstOrDefaultAsync(a => a.Id == address.Id && a.Disabled == false); if (existingAddress != null) { dbContext.Entry(existingAddress).State = EntityState.Detached; } dbContext.Entry(address).State = EntityState.Modified; await SaveAsync(dbContext); } else { var existingAddress = await _dbContext.Addresses .FirstOrDefaultAsync(a => a.Id == address.Id && a.Disabled == false); if (existingAddress != null) { _dbContext.Entry(existingAddress).State = EntityState.Detached; } _dbContext.Entry(address).State = EntityState.Modified; await SaveAsync(); } return(address); }
public CitiesService(VirtualBankDbContext dbContext, ICitiesRepository citiesRepo, IHttpContextAccessor httpContextAccessor) { _dbContext = dbContext; _citiesRepo = citiesRepo; _httpContextAccessor = httpContextAccessor; }
public CreditCardsService(VirtualBankDbContext dbContext, IHttpContextAccessor httpContextAccessor, ICreditCardsRepository creditCardsRepo) { _dbContext = dbContext; _httpContextAccessor = httpContextAccessor; _creditCardsRepo = creditCardsRepo; }
public async Task <Branch> AddAsync(VirtualBankDbContext dbContext, Branch branch) { await dbContext.Branches.AddAsync(branch); await SaveAsync(dbContext); return(branch); }
public async Task <BankAccount> AddAsync(VirtualBankDbContext dbContext, BankAccount bankAccount) { await dbContext.BankAccounts.AddAsync(bankAccount); await SaveAsync(dbContext); return(bankAccount); }
public DistrictsService(VirtualBankDbContext dbContext, IDistrictsRepository districtsRepo, IHttpContextAccessor httpContextAccessor) { _dbContext = dbContext; _districtsRepo = districtsRepo; _httpContextAccessor = httpContextAccessor; }
public async Task <CashTransaction> AddAsync(VirtualBankDbContext dbContext, CashTransaction transaction) { await dbContext.CashTransactions.AddAsync(transaction); await SaveAsync(dbContext); return(transaction); }
public async Task <Customer> AddAsync(VirtualBankDbContext dbContext, Customer customer) { await _dbContext.Customers.AddAsync(customer); await SaveAsync(dbContext); return(customer); }
public BranchService(VirtualBankDbContext dbContext, IHttpContextAccessor httpContextAccessor, IBranchRepository branchRepo, IAddressRepository addressRepo) { _dbContext = dbContext; _httpContextAccessor = httpContextAccessor; _branchRepo = branchRepo; _addressRepo = addressRepo; }
public DebitCardsService(VirtualBankDbContext dbContext, IHttpContextAccessor httpContextAccessor, IDebitCardsRepository debitCardsRepo, IBankAccountRepository bankAccountRepo) { _dbContext = dbContext; _httpContextAccessor = httpContextAccessor; _debitCardsRepo = debitCardsRepo; _bankAccountRepo = bankAccountRepo; }
public async Task SaveAsync(VirtualBankDbContext dbContext = null) { if (dbContext != null) { await dbContext.SaveChangesAsync(); } else { await _dbContext.SaveChangesAsync(); } }
public CashTransactionsService(VirtualBankDbContext dbContext, ICustomerRepository customersRepo, IBankAccountRepository bankAccountRepo, ICashTransactionsRepository cashTransactionsRepo, IHttpContextAccessor httpContextAccessor) { _dbContext = dbContext; _customerRepo = customersRepo; _bankAccountRepo = bankAccountRepo; _cashTransactionsRepo = cashTransactionsRepo; _httpContextAccessor = httpContextAccessor; }
public CustomerService(VirtualBankDbContext dbContext, ICustomerRepository customerRepo, IAddressRepository addressRepo, IBankAccountRepository bankAccountRepo, IHttpContextAccessor httpContextAccessor) { _dbContext = dbContext; _customerRepo = customerRepo; _addressRepo = addressRepo; _bankAccountRepo = bankAccountRepo; _httpContextAccessor = httpContextAccessor; }
public async Task <CashTransaction> UpdateAsync(VirtualBankDbContext dbContext, CashTransaction transaction) { var existingCashTransaction = await dbContext.CashTransactions.Where(c => c.Id == transaction.Id && transaction.Disabled == false) .FirstOrDefaultAsync(); if (existingCashTransaction != null) { dbContext.Entry(existingCashTransaction).State = EntityState.Detached; } dbContext.Entry(transaction).State = EntityState.Modified; await SaveAsync(dbContext); return(transaction); }
public async Task <Customer> UpdateAsync(VirtualBankDbContext dbContext, Customer customer) { var existingCustomer = await _dbContext.Customers.Where(c => c.Id == customer.Id && c.Disabled == false) .FirstOrDefaultAsync(); if (existingCustomer != null) { _dbContext.Entry(existingCustomer).State = EntityState.Detached; } _dbContext.Entry(customer).State = EntityState.Modified; await SaveAsync(dbContext); return(customer); }
public async Task <bool> RemoveAsync(VirtualBankDbContext dbContext, int id) { var isDeleted = false; var customer = await _dbContext.Customers.FindAsync(id); if (customer != null) { customer.Disabled = true; await SaveAsync(dbContext); isDeleted = true; } return(isDeleted); }
public async Task <bool> RemoveAsync(VirtualBankDbContext dbContext, int id) { var isDeleted = false; var branch = await dbContext.Branches.FindAsync(id); if (branch != null) { branch.Disabled = true; await SaveAsync(dbContext); isDeleted = true; } return(isDeleted); }
public async Task <Branch> UpdateAsync(VirtualBankDbContext dbContext, Branch branch) { var existingBranch = await dbContext.Branches .FirstOrDefaultAsync(b => b.Id == branch.Id && b.Disabled == false); if (existingBranch != null) { dbContext.Entry(existingBranch).State = EntityState.Detached; } dbContext.Entry(branch).State = EntityState.Modified; await SaveAsync(dbContext); return(branch); }
public async Task <bool> RemoveAsync(VirtualBankDbContext dbContext, int id) { var isDeleted = false; var bankAccount = await dbContext.BankAccounts.FindAsync(id); if (bankAccount != null) { bankAccount.Disabled = true; await SaveAsync(dbContext); isDeleted = true; } return(isDeleted); }
public async Task <bool> RemoveAsync(VirtualBankDbContext dbContext, int id) { var transaction = await dbContext.CashTransactions.FindAsync(id); var isDeleted = false; if (transaction != null) { transaction.Disabled = true; await SaveAsync(dbContext); isDeleted = true; } return(isDeleted); }
public async Task <Address> AddAsync(Address address, VirtualBankDbContext dbContext = null) { if (dbContext != null) { await dbContext.Addresses.AddAsync(address); await SaveAsync(dbContext); } else { await _dbContext.Addresses.AddAsync(address); await SaveAsync(); } return(address); }
public async Task <BankAccount> UpdateAsync(VirtualBankDbContext dbContext, BankAccount bankAccount) { var existingBankAccount = await dbContext.BankAccounts .FirstOrDefaultAsync(b => b.Id == bankAccount.Id && b.Disabled == false); if (existingBankAccount != null) { dbContext.Entry(existingBankAccount).State = EntityState.Detached; } dbContext.Entry(bankAccount).State = EntityState.Modified; await SaveAsync(dbContext); return(bankAccount); }
public CashTransactionsRepository(VirtualBankDbContext dbContext) { _dbContext = dbContext; }
public DebitCardsRepository(VirtualBankDbContext dbContext) { _dbContext = dbContext; }
public async Task SaveAsync(VirtualBankDbContext dbContext) { await dbContext.SaveChangesAsync(); }
public CitiesRepository(VirtualBankDbContext dbContext) { _dbContext = dbContext; }
public CustomerRepository(VirtualBankDbContext dbContext) { _dbContext = dbContext; }
public DistrictsRepository(VirtualBankDbContext dbContext) { _dbContext = dbContext; }
public RecipientService(VirtualBankDbContext dbContext, IHttpContextAccessor httpContextAccessor) { _dbContext = dbContext; _httpContextAccessor = httpContextAccessor; }