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);
        }
Beispiel #2
0
        public override bool Execute()
        {
            if (!Verifier.CheckExpiredDate(ExpiredDate))
            {
                Information = StringSource.ExpiredDateStructureError();
                return(false);
            }
            if (!Verifier.CheckName(CardAccountName))
            {
                Information = StringSource.NameStructureError();
                return(false);
            }

            if (!Verifier.CheckName(CardType))
            {
                Information = StringSource.NameStructureError();
                return(false);
            }
            if (!Verifier.CheckName(CardAccountStatus))
            {
                Information = StringSource.NameStructureError();
                return(false);
            }



            var gen = new BLL.Generator()
            {
                NumberCount = DataSource.LengthCardAccountNumber
            };

            CartNumber = string.Empty;
            using (var bankservices = new BLL.ServiceReference1.BankServiceClient()) {
                BankAccount = bankservices.GetBankAccountById(IdBankAccount);
                if (BankAccount == null)
                {
                    Information = StringSource.BankAccountNotFound();
                    return(false);
                }

                using (var localrepos = new Repositories()) {
                    Client = localrepos.Customers.GetSingle(BankAccount.CustomerID);
                }
                if (Client == null)
                {
                    Information = StringSource.ClientNotFound();
                    return(false);
                }

                //if (BankAccount.CustomerID != IdClient) {
                //	Information=StringSource.BankAccountBelongsOtherCliente();
                //	return false;
                //}


                while (true)
                {
                    CartNumber = gen.NumberGenerate().ToString();
                    if (bankservices.GetBankAccountByNumber(CartNumber) == null)
                    {
                        break;
                    }
                }

                CardAccount = new CardAccount {
                    BankAccountID = BankAccount.BankAccountID,
                    CreatedDate   = DateTime.Now,
                    IsLocked      = false,
                    CustomerID    = Client.CustomerID,
                    CardNumber    = CartNumber,
                    ///////////////////////////////////////////////////////////////////////
                    Name        = CardAccountName,
                    IsDefault   = false,
                    CardType    = CardType,
                    ExpiredDate = ExpiredDate,
                    //ExtensionData=new System.Runtime.Serialization.ExtensionDataObject(),
                    Status = CardAccountStatus,
                    /////////////////////////////////////////////////
                };

                bankservices.AddCardAccount(CardAccount);
            }
            Information   = StringSource.CardAccountRegistred(CardAccount.CardNumber);
            IdCardAccount = CardAccount.CardAccountID;
            IdClient      = BankAccount.CustomerID;
            return(true);
        }