Example #1
0
        public override bool Execute()
        {
            if (IdBankAccount <= 0)
            {
                Information = StringSource.BankAccountNotFound();
                return(false);
            }

            using (var service = new BankServiceClient()) {
                BankAccount = service.GetBankAccountById(IdBankAccount);

                if (BankAccount != null)
                {
                    service.RemoveBankAccount(BankAccount);

                    Information = StringSource.BankAccountRemoved();
                    return(true);
                }
                else
                {
                    Information = StringSource.BankAccountNotFound();
                    return(false);
                }
            }
        }
Example #2
0
        public bool RemoveClientInformationById(int IdClient, bool isRemoveClient = false)
        {
            Customer client;

            using (var localrepos = new Repositories()) {
                client = localrepos.Customers.GetSingle(IdClient);
                if (client == null)
                {
                    return(false);
                }
            }


            if (client != null)
            {
                CardAccount[] cardaccounts = null;
                BankAccount   bankaccount  = null;
                using (var bankservice = new BankServiceClient()) {
                    cardaccounts = bankservice.GetCardAccountsByCustomerId(client.CustomerID);
                    if (cardaccounts != null)
                    {
                        for (int i = 0; i < cardaccounts.Length; i++)
                        {
                            bankaccount = bankservice.GetBankAccountById(cardaccounts[i].BankAccountID);
                            if (bankaccount != null)
                            {
                                bankservice.RemoveBankAccount(bankaccount);
                            }

                            bankservice.RemoveCardAccount(cardaccounts[i]);
                        }
                    }
                }

                if (isRemoveClient)
                {
                    using (var localrepos = new Repositories()) {
                        localrepos.Customers.Remove(client);
                        localrepos.SaveChanges();
                    }
                }
            }
            else
            {
                return(false);
            }

            return(true);
        }