Example #1
0
        public PartialViewResult CurrencyPartial()
        {
            List <Currency> currensies = service.GetAllCurrency().Where(c => c.CurrencyID != 1).ToList();
            CurrencyModel   model      = new CurrencyModel();

            foreach (var currency in currensies)
            {
                var item = new CurrencyItem()
                {
                    Name      = currency.Name,
                    BankBuys  = Math.Round(currency.Rate * 1.003) + "р",
                    BankCells = Math.Round(currency.Rate) + "р"
                };

                model.Rates.Add(item);
            }

            foreach (var currency in currensies)
            {
                foreach (var crossCurrency in currensies)
                {
                    if (currency.CurrencyID != crossCurrency.CurrencyID)
                    {
                        model.CrossRates.Add(currency.ShortName + "/" + crossCurrency.ShortName, Math.Round(currency.Rate / crossCurrency.Rate, 3).ToString());
                    }
                }
            }

            return(PartialView("CurrencyPartial", model));
        }
Example #2
0
        public override bool Execute()
        {
            using (var bankservice = new BankServiceClient()) {
                AllCurrencies = bankservice.GetAllCurrency();
            }

            CurrenciesNames      = new List <string>();
            CurrenciesShortNames = new List <string>();
            CurrenciesIds        = new List <string>();
            CurrenciesRates      = new List <string>();

            foreach (var el in AllCurrencies)
            {
                CurrenciesIds.Add(el.CurrencyID.ToString());
                CurrenciesNames.Add(el.Name);
                CurrenciesRates.Add(el.Rate.ToString());
                CurrenciesShortNames.Add(el.ShortName);
            }

            return(true);
        }
Example #3
0
        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);
        }
Example #4
0
        public override bool Execute()
        {
            foreach (var el in CurrenciesNames)
            {
                if (!Verifier.CheckName(el))
                {
                    Information = StringSource.NameStructureError();
                    return(false);
                }
            }
            foreach (var el in CurrenciesShortNames)
            {
                if (!Verifier.CheckName(el))
                {
                    Information = StringSource.NameStructureError();
                    return(false);
                }
            }
            foreach (var el in CurrenciesRates)
            {
                if (!Verifier.CheckCurrencyCoef(el))
                {
                    Information = StringSource.CurrencyCoefStructureError();
                    return(false);
                }
            }


            var currencies = new List <Currency>();
            int idd        = -1;

            for (int i = 0; i < CurrenciesRates.Count; i++, idd = -1)
            {
                if (!int.TryParse(CurrenciesId.ElementAt(i), out idd))
                {
                    idd = -1;
                }
                currencies.Add(new Currency {
                    CurrencyID = idd,
                    Name       = CurrenciesNames.ElementAt(i),
                    ShortName  = CurrenciesShortNames.ElementAt(i),
                    Rate       = double.Parse(CurrenciesRates.ElementAt(i)),
                });
            }
            using (var bankaccoun = new BankServiceClient()) {
                //bankaccoun.RemoveAllCurrency();
                var oldcurr = bankaccoun.GetAllCurrency();
                foreach (var el in oldcurr)
                {
                    if (currencies.Where(vl => vl.CurrencyID == el.CurrencyID).Count() <= 0)
                    {
                        bankaccoun.RemoveCurrency(el);
                    }
                }

                foreach (var el in currencies)
                {
                    if (el.CurrencyID == -1)
                    {
                        bankaccoun.AddCurrency(el);
                    }
                    else
                    {
                        bankaccoun.UpdateCurrency(el);
                    }
                }
            }

            Information = StringSource.EditedIsTrue();
            return(true);
        }