/// <summary>
        /// Updates the currency
        /// </summary>
        /// <param name="currencyId">Currency identifier</param>
        /// <param name="name">The name</param>
        /// <param name="currencyCode">The currency code</param>
        /// <param name="rate">The rate</param>
        /// <param name="displayLocale">The display locale</param>
        /// <param name="customFormatting">The custom formatting</param>
        /// <param name="published">A value indicating whether the entity is published</param>
        /// <param name="displayOrder">The display order</param>
        /// <param name="createdOn">The date and time of instance creation</param>
        /// <param name="updatedOn">The date and time of instance update</param>
        /// <returns>A currency</returns>
        public static Currency UpdateCurrency(int currencyId, string name,
                                              string currencyCode, decimal rate, string displayLocale,
                                              string customFormatting, bool published, int displayOrder,
                                              DateTime createdOn, DateTime updatedOn)
        {
            try
            {
                CultureInfo ci = CultureInfo.GetCultureInfo(displayLocale);
            }
            catch (Exception)
            {
                throw new NopException("Specified display locale culture is not supported");
            }

            createdOn = DateTimeHelper.ConvertToUtcTime(createdOn);
            updatedOn = DateTimeHelper.ConvertToUtcTime(updatedOn);

            DBCurrency dbItem = DBProviderManager <DBCurrencyProvider> .Provider.UpdateCurrency(currencyId,
                                                                                                name, currencyCode, rate, displayLocale, customFormatting,
                                                                                                published, displayOrder, createdOn, updatedOn);

            Currency currency = DBMapping(dbItem);

            if (CurrencyManager.CacheEnabled)
            {
                NopCache.RemoveByPattern(CURRENCIES_PATTERN_KEY);
            }
            return(currency);
        }
        /// <summary>
        /// Gets a currency
        /// </summary>
        /// <param name="currencyId">Currency identifier</param>
        /// <returns>Currency</returns>
        public static Currency GetCurrencyById(int currencyId)
        {
            if (currencyId == 0)
            {
                return(null);
            }

            string key  = string.Format(CURRENCIES_BY_ID_KEY, currencyId);
            object obj2 = NopCache.Get(key);

            if (CurrencyManager.CacheEnabled && (obj2 != null))
            {
                return((Currency)obj2);
            }

            DBCurrency dbItem = DBProviderManager <DBCurrencyProvider> .Provider.GetCurrencyById(currencyId);

            Currency currency = DBMapping(dbItem);

            if (CurrencyManager.CacheEnabled)
            {
                NopCache.Max(key, currency);
            }
            return(currency);
        }
        /// <summary>
        /// Updates the currency
        /// </summary>
        /// <param name="CurrencyID">Currency identifier</param>
        /// <param name="Name">The name</param>
        /// <param name="CurrencyCode">The currency code</param>
        /// <param name="Rate">The rate</param>
        /// <param name="DisplayLocale">The display locale</param>
        /// <param name="CustomFormatting">The custom formatting</param>
        /// <param name="Published">A value indicating whether the entity is published</param>
        /// <param name="DisplayOrder">The display order</param>
        /// <param name="CreatedOn">The date and time of instance creation</param>
        /// <param name="UpdatedOn">The date and time of instance update</param>
        /// <returns>A currency</returns>
        public static Currency UpdateCurrency(int CurrencyID, string Name, string CurrencyCode, decimal Rate,
                                              string DisplayLocale, string CustomFormatting, bool Published, int DisplayOrder, DateTime CreatedOn, DateTime UpdatedOn)
        {
            try
            {
                CultureInfo ci = CultureInfo.GetCultureInfo(DisplayLocale);
            }
            catch (Exception)
            {
                throw new NopException("Specified display locale culture is not supported");
            }

            CreatedOn = DateTimeHelper.ConvertToUtcTime(CreatedOn);
            UpdatedOn = DateTimeHelper.ConvertToUtcTime(UpdatedOn);

            DBCurrency dbItem = DBProviderManager <DBCurrencyProvider> .Provider.UpdateCurrency(CurrencyID, Name, CurrencyCode, Rate,
                                                                                                DisplayLocale, CustomFormatting, Published, DisplayOrder, CreatedOn, UpdatedOn);

            Currency currency = DBMapping(dbItem);

            if (CurrencyManager.CacheEnabled)
            {
                NopCache.RemoveByPattern(CURRENCIES_PATTERN_KEY);
            }
            return(currency);
        }
示例#4
0
 private bool Update()
 {
     return(DBCurrency.Update(
                this.guid,
                this.title,
                this.code,
                this.symbolLeft,
                this.symbolRight,
                this.decimalPointChar,
                this.thousandsPointChar,
                this.decimalPlaces,
                this.value,
                this.lastModified));
 }
示例#5
0
        private bool CheckIfUpdate(List <DBCurrency> currencies)
        {
            DB_Context context = new DB_Context();
            DBCurrency tmp     = currencies.First();
            DateTime   time    = DateTime.Now.ToLocalTime();

            //NEED TO CHANGE
            if (tmp.Date.AddHours(3) > DateTime.Now && (IsItTheSameDay(tmp.Date)))
            {
                return(true);
            }

            context.Dispose();
            return(false);
        }
示例#6
0
 private void GetCurrency(Guid guid)
 {
     using (IDataReader reader = DBCurrency.GetOne(guid))
     {
         if (reader.Read())
         {
             this.guid               = new Guid(reader["Guid"].ToString());
             this.title              = reader["Title"].ToString();
             this.code               = reader["Code"].ToString();
             this.symbolLeft         = reader["SymbolLeft"].ToString();
             this.symbolRight        = reader["SymbolRight"].ToString();
             this.decimalPointChar   = reader["DecimalPointChar"].ToString();
             this.thousandsPointChar = reader["ThousandsPointChar"].ToString();
             this.decimalPlaces      = reader["DecimalPlaces"].ToString();
             this.value              = Convert.ToDecimal(reader["Value"]);
             this.lastModified       = Convert.ToDateTime(reader["LastModified"]);
             this.created            = Convert.ToDateTime(reader["Created"]);
         }
     }
 }
示例#7
0
        private List <DBCurrency> UpdateValueToCurrenciesByNames(List <DBCurrency> Currencies, CurrencyLayerDotNet.Models.LiveModel RTRates)
        {
            List <DBCurrency> CurrenciesList = new List <DBCurrency>();

            foreach (var qoute in RTRates.quotes)
            {
                //here we get the full name of the country currency."ILS"="UDS_ILS_" and return the full name of the country.
                string     issuesCountryName = Currencies.Find(t => t.Initials == qoute.Key.Substring(3)).FullName;
                DBCurrency currency          = new DBCurrency()
                {
                    Value    = qoute.Value,
                    Initials = qoute.Key.Substring(3),
                    FullName = issuesCountryName,
                    Date     = DateTime.Now,
                    Flag     = ("UI/Images/" + qoute.Key.Substring(3) + ".png")
                };
                CurrenciesList.Add(currency);
            }
            return(CurrenciesList);
        }
示例#8
0
        private bool Create()
        {
            Guid newID = Guid.NewGuid();

            this.guid = newID;

            int rowsAffected = DBCurrency.Create(
                this.guid,
                this.title,
                this.code,
                this.symbolLeft,
                this.symbolRight,
                this.decimalPointChar,
                this.thousandsPointChar,
                this.decimalPlaces,
                this.value,
                this.lastModified,
                this.created);

            return(rowsAffected > 0);
        }
示例#9
0
        public static DataTable GetAll()
        {
            DataTable dataTable = new DataTable();

            dataTable.Columns.Add("Guid", typeof(Guid));
            dataTable.Columns.Add("Title", typeof(string));
            dataTable.Columns.Add("Code", typeof(string));
            dataTable.Columns.Add("SymbolLeft", typeof(string));
            dataTable.Columns.Add("SymbolRight", typeof(string));
            dataTable.Columns.Add("DecimalPointChar", typeof(string));
            dataTable.Columns.Add("ThousandsPointChar", typeof(string));
            dataTable.Columns.Add("DecimalPlaces", typeof(string));
            dataTable.Columns.Add("Value", typeof(decimal));
            dataTable.Columns.Add("LastModified", typeof(DateTime));
            dataTable.Columns.Add("Created", typeof(DateTime));

            using (IDataReader reader = DBCurrency.GetAll())
            {
                while (reader.Read())
                {
                    DataRow row = dataTable.NewRow();
                    row["Guid"]               = reader["Guid"];
                    row["Title"]              = reader["Title"];
                    row["Code"]               = reader["Code"];
                    row["SymbolLeft"]         = reader["SymbolLeft"];
                    row["SymbolRight"]        = reader["SymbolRight"];
                    row["DecimalPointChar"]   = reader["DecimalPointChar"];
                    row["ThousandsPointChar"] = reader["ThousandsPointChar"];
                    row["DecimalPlaces"]      = reader["DecimalPlaces"];
                    row["Value"]              = reader["Value"];
                    row["LastModified"]       = reader["LastModified"];
                    row["Created"]            = reader["Created"];

                    dataTable.Rows.Add(row);
                }
            }

            return(dataTable);
        }
示例#10
0
        private static Currency DBMapping(DBCurrency dbItem)
        {
            if (dbItem == null)
            {
                return(null);
            }

            Currency item = new Currency();

            item.CurrencyId       = dbItem.CurrencyId;
            item.Name             = dbItem.Name;
            item.CurrencyCode     = dbItem.CurrencyCode;
            item.Rate             = dbItem.Rate;
            item.DisplayLocale    = dbItem.DisplayLocale;
            item.CustomFormatting = dbItem.CustomFormatting;
            item.Published        = dbItem.Published;
            item.DisplayOrder     = dbItem.DisplayOrder;
            item.CreatedOn        = dbItem.CreatedOn;
            item.UpdatedOn        = dbItem.UpdatedOn;

            return(item);
        }
示例#11
0
 public double GetConvertCalculation(DBCurrency From, DBCurrency To, string amount)
 {
     return(new Bl_imp().ConvertCalculation(From, To, amount));
 }
示例#12
0
 public static bool Delete(Guid guid)
 {
     return(DBCurrency.Delete(guid));
 }
示例#13
0
 public override void Initialize()
 {
     base.Initialize();
     dbEntity = new DBCurrency(connManager);
 }
示例#14
0
 //Here we use to calculate the moeny convert from X to Y with the amount by the formula.
 public double ConvertCalculation(DBCurrency From, DBCurrency To, string amount)
 {
     return(Convert.ToDouble(amount) * Convert.ToDouble(To.Value) / Convert.ToDouble(From.Value));
 }