Esempio n. 1
0
        /// <summary>
        /// Gets a credit card type
        /// </summary>
        /// <param name="CreditCardTypeID">Credit card type identifier</param>
        /// <returns>Credit card type</returns>
        public static CreditCardType GetCreditCardTypeByID(int CreditCardTypeID)
        {
            if (CreditCardTypeID == 0)
            {
                return(null);
            }

            string key  = string.Format(CREDITCARDS_BY_ID_KEY, CreditCardTypeID);
            object obj2 = NopCache.Get(key);

            if (CreditCardTypeManager.CacheEnabled && (obj2 != null))
            {
                return((CreditCardType)obj2);
            }

            DBCreditCardType dbItem = DBProviderManager <DBCreditCardTypeProvider> .Provider.GetCreditCardTypeByID(CreditCardTypeID);

            CreditCardType creditCardType = DBMapping(dbItem);

            if (CreditCardTypeManager.CacheEnabled)
            {
                NopCache.Max(key, creditCardType);
            }
            return(creditCardType);
        }
        /// <summary>
        /// Updates the credit card type
        /// </summary>
        /// <param name="creditCardType">Credit card type</param>
        public void UpdateCreditCardType(CreditCardType creditCardType)
        {
            if (creditCardType == null)
            {
                throw new ArgumentNullException("creditCardType");
            }

            creditCardType.Name          = CommonHelper.EnsureNotNull(creditCardType.Name);
            creditCardType.Name          = CommonHelper.EnsureMaximumLength(creditCardType.Name, 100);
            creditCardType.SystemKeyword = CommonHelper.EnsureNotNull(creditCardType.SystemKeyword);
            creditCardType.SystemKeyword = CommonHelper.EnsureMaximumLength(creditCardType.SystemKeyword, 100);


            if (!_context.IsAttached(creditCardType))
            {
                _context.CreditCardTypes.Attach(creditCardType);
            }

            _context.SaveChanges();

            if (this.CacheEnabled)
            {
                _cacheManager.RemoveByPattern(CREDITCARDS_PATTERN_KEY);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Inserts a credit card type
        /// </summary>
        /// <param name="Name">The name</param>
        /// <param name="SystemKeyword">The system keyword</param>
        /// <param name="DisplayOrder">The display order</param>
        /// <param name="Deleted">A value indicating whether the entity has been deleted</param>
        /// <returns>A credit card type</returns>
        public static CreditCardType InsertCreditCardType(string Name, string SystemKeyword, int DisplayOrder, bool Deleted)
        {
            DBCreditCardType dbItem = DBProviderManager <DBCreditCardTypeProvider> .Provider.InsertCreditCardType(Name, SystemKeyword, DisplayOrder, Deleted);

            CreditCardType creditCardType = DBMapping(dbItem);

            if (CreditCardTypeManager.CacheEnabled)
            {
                NopCache.RemoveByPattern(CREDITCARDS_PATTERN_KEY);
            }
            return(creditCardType);
        }
Esempio n. 4
0
        /// <summary>
        /// Marks a credit card type as deleted
        /// </summary>
        /// <param name="CreditCardTypeID">Credit card type identifier</param>
        public static void MarkCreditCardTypeAsDeleted(int CreditCardTypeID)
        {
            CreditCardType creditCardType = GetCreditCardTypeByID(CreditCardTypeID);

            if (creditCardType != null)
            {
                UpdateCreditCardType(creditCardType.CreditCardTypeID, creditCardType.Name, creditCardType.SystemKeyword, creditCardType.DisplayOrder, true);
            }
            if (CreditCardTypeManager.CacheEnabled)
            {
                NopCache.RemoveByPattern(CREDITCARDS_PATTERN_KEY);
            }
        }
        private static CreditCardType DBMapping(DBCreditCardType dbItem)
        {
            if (dbItem == null)
                return null;

            CreditCardType item = new CreditCardType();
            item.CreditCardTypeID = dbItem.CreditCardTypeID;
            item.Name = dbItem.Name;
            item.SystemKeyword = dbItem.SystemKeyword;
            item.DisplayOrder = dbItem.DisplayOrder;
            item.Deleted = dbItem.Deleted;

            return item;
        }
Esempio n. 6
0
        private static CreditCardType DBMapping(DBCreditCardType dbItem)
        {
            if (dbItem == null)
            {
                return(null);
            }

            CreditCardType item = new CreditCardType();

            item.CreditCardTypeID = dbItem.CreditCardTypeID;
            item.Name             = dbItem.Name;
            item.SystemKeyword    = dbItem.SystemKeyword;
            item.DisplayOrder     = dbItem.DisplayOrder;
            item.Deleted          = dbItem.Deleted;

            return(item);
        }
Esempio n. 7
0
        private static CreditCardTypeCollection DBMapping(DBCreditCardTypeCollection dbCollection)
        {
            if (dbCollection == null)
            {
                return(null);
            }

            CreditCardTypeCollection collection = new CreditCardTypeCollection();

            foreach (DBCreditCardType dbItem in dbCollection)
            {
                CreditCardType item = DBMapping(dbItem);
                collection.Add(item);
            }

            return(collection);
        }
        public CreditCardType SaveInfo()
        {
            CreditCardType creditCardType = this.PaymentService.GetCreditCardTypeById(this.CreditCardTypeId);
            if (creditCardType != null)
            {
                creditCardType.Name = txtName.Text;
                creditCardType.SystemKeyword = txtSystemKeyword.Text;
                creditCardType.DisplayOrder = txtDisplayOrder.Value;
                this.PaymentService.UpdateCreditCardType(creditCardType);
            }
            else
            {
                creditCardType = new CreditCardType()
                {
                    Name = txtName.Text,
                    SystemKeyword = txtSystemKeyword.Text,
                    DisplayOrder = txtDisplayOrder.Value
                };
                this.PaymentService.InsertCreditCardType(creditCardType);
            }

            return creditCardType;
        }
Esempio n. 9
0
        /// <summary>
        /// Updates the credit card type
        /// </summary>
        /// <param name="creditCardType">Credit card type</param>
        public void UpdateCreditCardType(CreditCardType creditCardType)
        {
            if (creditCardType == null)
                throw new ArgumentNullException("creditCardType");

            creditCardType.Name = CommonHelper.EnsureNotNull(creditCardType.Name);
            creditCardType.Name = CommonHelper.EnsureMaximumLength(creditCardType.Name, 100);
            creditCardType.SystemKeyword = CommonHelper.EnsureNotNull(creditCardType.SystemKeyword);
            creditCardType.SystemKeyword = CommonHelper.EnsureMaximumLength(creditCardType.SystemKeyword, 100);

            if (!_context.IsAttached(creditCardType))
                _context.CreditCardTypes.Attach(creditCardType);

            _context.SaveChanges();

            if (this.CacheEnabled)
            {
                _cacheManager.RemoveByPattern(CREDITCARDS_PATTERN_KEY);
            }
        }