Exemplo n.º 1
0
 public COMPTA_ExchangeRate CreateExchangeRate(COMPTA_ExchangeRate exchangeRateToAdd)
 {
     using(SUPERPEntities context = new SUPERPEntities(false))
     {
         var exchangeRate = context.COMPTA_ExchangeRate.Add(exchangeRateToAdd);
         context.SaveChanges();
         return exchangeRate;
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public COMPTA_ExchangeRate GetLastExchangeRate()
        {
            var result = comptabilityDal.GetLastExchangeRate();

            if ( result == null || DateTime.Now - result.updatedDate > new TimeSpan(1, 0, 0, 0, 0) )
            {
                // Call Update WebService for ExchangeRate Update =)
                //comptabilityDal.
                // ReGet the value updated
                CurrencyConvertor.CurrencyConvertorSoapClient client = new CurrencyConvertor.CurrencyConvertorSoapClient("CurrencyConvertorSoap",new System.ServiceModel.EndpointAddress("http://www.webservicex.net/CurrencyConvertor.asmx"));

                try
                {
                    COMPTA_ExchangeRate exchangeRate = new COMPTA_ExchangeRate();

                    exchangeRate.EURO_AUD = client.ConversionRate(Currency.EUR, Currency.AUD);
                    exchangeRate.EURO_GBP = client.ConversionRate(Currency.EUR, Currency.GBP);
                    exchangeRate.EURO_USD = client.ConversionRate(Currency.EUR, Currency.USD);
                    exchangeRate.EURO_ZAR = client.ConversionRate(Currency.EUR, Currency.ZAR);
                    exchangeRate.USD_EURO = client.ConversionRate(Currency.USD, Currency.EUR);
                    exchangeRate.updatedDate = DateTime.Now;

                    comptabilityDal.CreateExchangeRate(exchangeRate);

                    result = comptabilityDal.GetLastExchangeRate();
                }
                catch (Exception e)
                {

                }

            }

            return result;
        }
Exemplo n.º 3
0
        public COMPTA_ExchangeRate EditExchangeRate(COMPTA_ExchangeRate exchangeRateToEdit)
        {
            using(SUPERPEntities context = new SUPERPEntities(false))
            {
                var exchangeRate = context.COMPTA_ExchangeRate.Find(exchangeRateToEdit.id);

                if (exchangeRate == null)
                    return null;

                exchangeRate = exchangeRateToEdit;
                context.SaveChanges();
                return exchangeRate;
            }
        }