Example #1
0
        public static decimal GetBasicPrice(string CurrencyCode, decimal Price)
        {
            decimal BasicPrice = 0;
            DataAccess da = new DataAccess();
            string BasicCurrencyCode = da.getBasicCurrencyCode();
            decimal RateUsd = da.getCurrencyRateValue("USD");
            decimal RateEur = da.getCurrencyRateValue("EUR");
            decimal RateRur = da.getCurrencyRateValue("RUR");

            if (BasicCurrencyCode.Equals(CurrencyCode))
            {
                BasicPrice = Price;
            }
            else
            {
                if (BasicCurrencyCode.Contains("USD"))
                {
                    if (CurrencyCode.Contains("BYR"))
                    {
                        BasicPrice = Price / RateUsd;
                    }
                    if (CurrencyCode.Contains("EUR"))
                    {
                        BasicPrice = Price * RateEur / RateUsd;
                    }
                    if (CurrencyCode.Contains("RUR"))
                    {
                        BasicPrice = Price * RateRur / RateUsd;
                    }
                }
                if (BasicCurrencyCode.Contains("EUR"))
                {
                    if (CurrencyCode.Contains("BYR"))
                    {
                        BasicPrice = Price / RateEur;
                    }
                    if (CurrencyCode.Contains("USD"))
                    {
                        BasicPrice = Price * RateUsd / RateEur;
                    }
                    if (CurrencyCode.Contains("RUR"))
                    {
                        BasicPrice = Price * RateRur / RateEur;
                    }
                }

                if (BasicCurrencyCode.Contains("RUR"))
                {
                    if (CurrencyCode.Contains("BYR"))
                    {
                        BasicPrice = Price / RateRur;
                    }
                    if (CurrencyCode.Contains("EUR"))
                    {
                        BasicPrice = Price * RateEur / RateRur;
                    }
                    if (CurrencyCode.Contains("USD"))
                    {
                        BasicPrice = Price * RateUsd / RateRur;
                    }
                }

                if (BasicCurrencyCode.Contains("BYR"))
                {
                    if (CurrencyCode.Contains("USD"))
                    {
                        BasicPrice = Price * RateUsd;
                    }
                    if (CurrencyCode.Contains("EUR"))
                    {
                        BasicPrice = Price * RateEur;
                    }
                    if (CurrencyCode.Contains("RUR"))
                    {
                        BasicPrice = Price * RateRur;
                    }
                }
            }
            return BasicPrice;
        }