Exemplo n.º 1
0
        /// <summary>
        /// Gets the Promotion dto without caching the results.
        /// </summary>
        /// <param name="promotionId">The promotion id.</param>
        /// <returns></returns>
        public static PromotionDto GetPromotionDto(int promotionId)
        {
            // Assign new cache key, specific for site guid and response groups requested
            //string cacheKey = MarketingCache.CreateCacheKey("Promotion", PromotionId.ToString());

            PromotionDto dto = null;

            // check cache first
            //object cachedObject = MarketingCache.Get(cacheKey);

            //if (cachedObject != null)
            //    dto = (PromotionDto)cachedObject;

            // Load the object
            if (dto == null)
            {
                PromotionAdmin admin = new PromotionAdmin();
                admin.Load(promotionId);
                dto = admin.CurrentDto;

                // Insert to the cache collection
                //MarketingCache.Insert(cacheKey, dto, MarketingConfiguration.CacheConfig.PromotionCollectionTimeout);
            }

            return(dto);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets promotion dto based on the date passed. Only promotions that are active for the period specified (plus 1 week) will be returned.
        /// </summary>
        /// <param name="dateTime">The date time.</param>
        /// <returns></returns>
        public static PromotionDto GetPromotionDto(DateTime dateTime)
        {
            PromotionAdmin admin = new PromotionAdmin();

            admin.Load(dateTime);
            return(admin.CurrentDto);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Saves the promotion.
        /// </summary>
        /// <param name="dto">The dto.</param>
        public static void SavePromotion(PromotionDto dto)
        {
            if (dto == null)
            {
                throw new ArgumentNullException("dto", String.Format("PromotionDto can not be null"));
            }

            //TODO: check concurrency when updating the records

            //TODO: need to check security roles here,
            // The procedure will be following:
            // 1. Retrieve the record from the database for each category that is about to be updated
            // 2. Check Write permissions (if failed generate the error and exit)
            // 3. Otherwise proceed to update
            // Continue with security checks and other operations

            /*
             * foreach (PromotionDto.PromotionRow row in dto.Promotion.Rows)
             * {
             *  // Check Security
             *  IDataReader reader = DataHelper.CreateDataReader(dto.PromotionSecurity, String.Format("PromotionId = -1 or PromotionId = {0}", row.PromotionId));
             *  PermissionRecordSet recordSet = new PermissionRecordSet(PermissionHelper.ConvertReaderToRecords(reader));
             *  if (!PermissionManager.CheckPermission(PromotionScope.Promotion, Permission.Read, recordSet))
             *  {
             *      row.Delete();
             *      continue;
             *  }
             * }
             * */


            PromotionAdmin admin = new PromotionAdmin(dto);

            admin.Save();
        }
Exemplo n.º 4
0
    /// <summary>
    /// 
    /// </summary>
    /// <returns></returns>
    protected string DiscountTypeName(object DiscountTypeID)
    {
        if (DiscountTypeID != null)
        {
            int discTypeID = int.Parse(DiscountTypeID.ToString());

            PromotionAdmin promotionAdmin = new PromotionAdmin();
            DiscountType entity = promotionAdmin.GetByDiscountTypeID(discTypeID);

            if (entity != null)
                return entity.Name;
        }
        return "";
    }
Exemplo n.º 5
0
    /// <summary>
    /// Bind Discount type dropdownlist
    /// </summary>
    private void BindDiscountTypeList()
    {
        PromotionAdmin AdminAccess = new PromotionAdmin();
        ddlDiscountTypes.DataSource = AdminAccess.GetAllDiscountTypes();
        ddlDiscountTypes.DataTextField = "Name";
        ddlDiscountTypes.DataValueField = "DiscountTypeId";
        ddlDiscountTypes.DataBind();

        ListItem li = new ListItem("All", "0");
        ddlDiscountTypes.Items.Insert(0, li);
    }