public bool SaveCouponActivityWebConfig(WebCouponActivity configObject, string userName)
        {
            bool result = false;

            try
            {
                if (configObject != null)
                {
                    configObject.PromotionDescription = string.Empty;
                    configObject.PromotionCodeChannel = string.Empty;
                    result = DbGungnirManager.Execute(conn => handler.SaveCouponActivityWebConfig(conn, configObject, userName));
                    if (result)
                    {
                        var key = configObject.ActivityId == -1 ? configObject.ActivityKey?.ToString() : configObject.ActivityId.ToString();
                        using (var client = new Service.Config.CacheClient())
                        {
                            var serviceResult = client.RemoveRedisCacheKey("Config1", $"WebCouponActivity/{key}");
                            serviceResult.ThrowIfException(true);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                var exception = new ActivityException(1, "SaveCouponActivityWebConfig", ex);
                Logger.Error("SaveCouponActivityWebConfig", exception);
                throw ex;
            }
            return(result);
        }
        public ActionResult CouponActivityWebConfig(string id = "-1")
        {
            WebCouponActivity          model  = ActivityManager.GetCurrentWebCouponActivity(id);
            WebCouponActivityRuleModel coupon = ActivityManager.GetCouponRule(model.PromotionRuleGUID.GetValueOrDefault()) ?? new WebCouponActivityRuleModel();

            ViewData["CouponRuleModel"] = coupon;
            return(View(model));
        }
        public JsonResult SaveCouponActivityWebConfig(string configStr)
        {
            WebCouponActivity configObject = JsonConvert.DeserializeObject <WebCouponActivity>(configStr);

            string userName = HttpContext.User.Identity.Name;

            bool result = ActivityManager.SaveCouponActivityWebConfig(configObject, userName);

            return(Json(result));
        }
        public bool SaveCouponActivityWebConfig(SqlConnection conn, WebCouponActivity configObject, string userName)
        {
            var result = false;
            int rows   = DALActivity.SaveCouponActivityWebConfig(conn, configObject, userName);

            if (rows > 0)
            {
                result = true;
            }
            return(result);
        }
        public WebCouponActivity GetCurrentWebCouponActivity(SqlConnection conn, string id)
        {
            int activityId;
            WebCouponActivity activity = null;

            if (int.TryParse(id, out activityId))
            {
                activity = DALActivity.GetCurrentWebCouponActivityByActivityId(conn, activityId);
            }
            else
            {
                var activityKey = id;
                activity = DALActivity.GetCurrentWebCouponActivityByActivityKey(conn, activityKey);
            }
            return(activity);
        }
        public WebCouponActivity GetCurrentWebCouponActivity(string id)
        {
            WebCouponActivity result = null;

            try
            {
                result = DbGungnirReadOnlyManager.Execute(conn => handler.GetCurrentWebCouponActivity(conn, id)) ?? new WebCouponActivity()
                {
                    ActivityId  = -1,
                    ActivityKey = new Guid(Guid.NewGuid().ToString("N")),
                    StartDate   = DateTime.Today,
                    EndDate     = DateTime.Today
                };
            }
            catch (Exception ex)
            {
                var exception = new ActivityException(1, "GetCurrentWebCouponActivity", ex);
                Logger.Error("GetCurrentWebCouponActivity", exception);
            }

            return(result);
        }
示例#7
0
        public static int SaveCouponActivityWebConfig(SqlConnection conn, WebCouponActivity configObject, string userName)
        {
            var sql = @"INSERT  INTO [Gungnir].[dbo].[PromotionActivityWebConfig]
        ( SmallBannerImageUrl ,
          BigBannerImageUrl ,
          SmallContentImageUrl ,
          BigContentImageUrl ,
          ButtonBackGroundColor ,
          ButtonTextColor ,
          ButtonText ,
          Url ,
          IsSendCoupon ,
          LayerButtonText ,
          LayerButtonBackGroundColor ,
          LayerButtonTextColor ,
          PromotionRuleId ,
          PromotionMinMoney ,
          PromotionDiscount ,
          StartDate ,
          EndDate ,
          PromotionDescription ,
          PromotionCodeChannel ,
          CreatedUser ,
          ActivityId ,
          ActivityKey ,
          PromotionRuleGUID
        )
VALUES  ( @SmallBannerImageUrl ,
          @BigBannerImageUrl ,
          @SmallContentImageUrl ,
          @BigContentImageUrl ,
          @ButtonBackGroundColor ,
          @ButtonTextColor ,
          @ButtonText ,
          @Url ,
          @IsSendCoupon ,
          @LayerButtonText ,
          @LayerButtonBackGroundColor ,
          @LayerButtonTextColor ,
          @PromotionRuleId ,
          @PromotionMinMoney ,
          @PromotionDiscount ,
          @StartDate ,
          @EndDate ,
          @PromotionDescription ,
          @PromotionCodeChannel ,
          @CreatedUser ,
          @ActivityId ,
          @ActivityKey ,
          @PromotionRuleGUID
        );";

            SqlParameter[] parameters =
            {
                new SqlParameter("@ActivityId",                 configObject.ActivityId == -1 ? (int?)null : configObject.ActivityId),
                new SqlParameter("@SmallBannerImageUrl",        configObject.SmallBannerImageUrl),
                new SqlParameter("@BigBannerImageUrl",          configObject.BigBannerImageUrl),
                new SqlParameter("@SmallContentImageUrl",       configObject.SmallContentImageUrl),
                new SqlParameter("@BigContentImageUrl",         configObject.BigContentImageUrl),
                new SqlParameter("@ButtonBackGroundColor",      configObject.ButtonBackGroundColor),
                new SqlParameter("@ButtonTextColor",            configObject.ButtonTextColor),
                new SqlParameter("@ButtonText",                 configObject.ButtonText),
                new SqlParameter("@Url",                        configObject.Url),
                new SqlParameter("@IsSendCoupon",               configObject.IsSendCoupon),
                new SqlParameter("@LayerButtonText",            configObject.LayerButtonText),
                new SqlParameter("@LayerButtonBackGroundColor", configObject.LayerButtonBackGroundColor),
                new SqlParameter("@LayerButtonTextColor",       configObject.LayerButtonTextColor),
                //new SqlParameter("@PromotionType", configObject.PromotionType),
                new SqlParameter("@PromotionRuleId",            configObject.PromotionRuleId),
                new SqlParameter("@PromotionMinMoney",          configObject.PromotionMinMoney),
                new SqlParameter("@PromotionDiscount",          configObject.PromotionDiscount),
                new SqlParameter("@StartDate",                  configObject.StartDate == DateTime.MinValue?DateTime.Today:configObject.StartDate),
                new SqlParameter("@EndDate",                    configObject.EndDate == DateTime.MinValue?DateTime.Today:configObject.EndDate),
                new SqlParameter("@PromotionDescription",       configObject.PromotionDescription),
                new SqlParameter("@PromotionCodeChannel",       configObject.PromotionCodeChannel),
                new SqlParameter("@CreatedUser",                userName),
                new SqlParameter("@ActivityKey",                configObject.ActivityId == -1? configObject.ActivityKey: null),
                new SqlParameter("@PromotionRuleGUID",          configObject.PromotionRuleGUID),
            };

            var rows = SqlHelper.ExecuteNonQuery(conn, CommandType.Text, sql, parameters);

            return(rows);
        }