Beispiel #1
0
        /// <summary>
        /// Removes all customers
        /// </summary>
        public static void RemoveAllCustomers(int bankId)
        {
            BankdbContext context = new BankdbContext();

            // Then remove all customers of that bank
            List <Customer> customers = CustomerHandling.GetCustomersInBank(bankId);

            foreach (Customer c in customers)
            {
                CustomerHandling.RemoveCustomer(c.Id);
            }
            context.SaveChanges();
        }
Beispiel #2
0
        // Remove Bank entity information
        public static void RemoveBank(int bankId)
        {
            BankdbContext context = new BankdbContext();

            Models.Bank removeBank = context.Bank.Where(b => b.Id == bankId).SingleOrDefault();
            if (removeBank != null)
            {
                AccountHandling.RemoveAllAccounts(bankId);
                AccountHandling.ViewAllAccountsInOneBank(bankId);
                CustomerHandling.RemoveAllCustomers(bankId);
                CustomerHandling.ViewCustomersInBank(bankId);

                // Then remove the bank itself
                context.Bank.Remove(removeBank);
                context.SaveChanges();
                Console.WriteLine("Removed bank number {0}!\n", bankId);
            }
        }