public override bool Execute()
        {
            if (!Verifier.CheckBankAccountNumber(BankAccountNumber))
            {
                Information = StringSource.BankAccountNumberStructureError();
                return(false);
            }

            using (var bankService = new BLL.ServiceReference1.BankServiceClient()) {
                BankAccount = bankService.GetBankAccountByNumber(BankAccountNumber);

                if (BankAccount == null)
                {
                    Information = StringSource.BankAccountNotFound();
                    return(false);
                }

                Currency = bankService.GetCurrencyById(BankAccount.CurrencyID);
            }

            if (Currency == null)
            {
                Information = StringSource.CurrencyNotFound();
                return(false);
            }

            IdBankAccount     = BankAccount.BankAccountID;
            Balance           = BankAccount.Balance.ToString();
            CurrencyName      = Currency.Name;
            CurrencyShortName = Currency.ShortName;
            IdCurrency        = Currency.CurrencyID;
            Information       = StringSource.BankAccountAndClientInfo(BankAccount, Customer, Currency);
            return(true);
        }
Exemple #2
0
        public override bool Execute()
        {
            if (IdBankAccount <= 0)
            {
                Information = StringSource.BankAccountNotFound();
                return(false);
            }

            using (var bankService = new BLL.ServiceReference1.BankServiceClient()) {
                BankAccount = bankService.GetBankAccountById(IdBankAccount);

                if (BankAccount == null)
                {
                    Information = StringSource.BankAccountNotFound();
                    return(false);
                }

                Currency = bankService.GetCurrencyById(BankAccount.CurrencyID);
            }

            using (var local = new DAL.Repositories()){
                Customer = local.Customers.GetSingle(BankAccount.CustomerID);
            }

            if (Currency == null)
            {
                Information = StringSource.CurrencyNotFound();
                return(false);
            }

            IdBankAccount = BankAccount.BankAccountID;

            Information = StringSource.BankAccountAndClientInfo(BankAccount, Customer, Currency);
            return(true);
        }
        public override bool Execute()
        {
            var isbs = base.Execute();

            if (!isbs)
            {
                return(false);
            }

            int id = 0;

            using (var services = new BankServiceClient()) {
                id = LastElement == null ? 0 : LastElement.BankAccountID;
                if (!IsUpdate)
                {
                    if (IsNext)
                    {
                        CurrentList = services.GetNextBankAccounts(id, AmountElements).ToList();
                    }
                    else
                    {
                        if (FirstElement == null)
                        {
                            id = int.MaxValue;
                        }
                        else
                        {
                            id = FirstElement.BankAccountID;
                        }
                        CurrentList = services.GetPrevBankAccounts(id, AmountElements).ToList();
                    }
                }
                else
                {
                    CurrentList = services.GetNextBankAccounts(id - 1, AmountElements).ToList();
                }

                Currencies = services.GetAllCurrency().ToArray();
            }

            if (CurrentList != null && CurrentList.Count > 0)
            {
                FirstElement = CurrentList.First();
                LastElement  = CurrentList.Last();
            }
            else
            {
                FirstElement = null;
                LastElement  = null;
                Information  = StringSource.EndList();
                return(false);
            }

            Customer cust = null;
            Currency curr = null;

            using (var localrepos = new DAL.Repositories()) {
                Customers = localrepos.Customers.GetAll();
                foreach (var el in CurrentList)
                {
                    if (Customers.Count() > 0)
                    {
                        cust = Customers.FirstOrDefault(cs => cs.CustomerID == el.CustomerID);
                    }
                    if (Currencies.Count() > 0)
                    {
                        curr = Currencies.FirstOrDefault(cur => cur.CurrencyID == el.CurrencyID);
                    }
                    EntitiesInformation.Add(
                        StringSource.BankAccountAndClientInfo(el, cust, curr));
                    IdsEntities.Add(el.BankAccountID);
                }
            }
            Information = StringSource.Successfully();
            return(true);
        }