Ejemplo n.º 1
0
        public JsonResult AddVip(PromoteVipModel promoteVipModel, int[] scopes)
        {
            try
            {
                var sb = new StringBuilder();
                this.promoteVipService = new PromoteVipService();
                promoteVipModel.EmployeeID = this.SystemUserSession.EmployeeID;
                promoteVipModel.Status = 1;

                var promoteVip = DataTransfer.Transfer<Promote_Vip>(promoteVipModel, typeof(PromoteVipModel));

                var promoteVipScopeList = new List<Promote_Vip_Scope>();
                foreach (var scope in scopes)
                {
                    var promoteVipScope = new Promote_Vip_Scope { ProductID = scope };
                    promoteVipScopeList.Add(promoteVipScope);
                    sb.Append(scope + ",");
                }

                // 验证相同商品是否参与其他促销
                var products = this.VerifyPromote(0, sb.ToString());
                if (!string.IsNullOrEmpty(products))
                {
                    return this.Json(new AjaxResponse(0, "以下商品已参加其他促销活动:" + products));
                }

                promoteVip.Scopes = promoteVipScopeList;
                this.promoteVipService.Add(promoteVip);
            }
            catch (Exception exception)
            {
                return this.Json(new AjaxResponse(0, "添加失败!" + exception.Message));
            }

            return this.Json(new AjaxResponse(1, "添加成功!"));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 添加活动商品.
        /// </summary>
        /// <param name="promoteVipScope">
        /// 活动商品实体.
        /// </param>
        /// <param name="transaction">
        /// 数据事务.
        /// </param>
        /// <returns>
        /// The <see cref="int"/>.
        /// </returns>
        public int Insert(Promote_Vip_Scope promoteVipScope, SqlTransaction transaction)
        {
            if (promoteVipScope == null)
            {
                throw new ArgumentNullException("promoteVipScope");
            }

            var parameters = new List<SqlParameter>
                                 {
                                     this.SqlServer.CreateSqlParameter(
                                         "PromoteVipID",
                                         SqlDbType.Int,
                                         promoteVipScope.PromoteVipID,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "ProductID",
                                         SqlDbType.NVarChar,
                                         promoteVipScope.ProductID,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "ReferenceID",
                                         SqlDbType.Int,
                                         promoteVipScope.ID,
                                         ParameterDirection.Output)
                                 };

            this.SqlServer.ExecuteNonQuery(
                CommandType.StoredProcedure,
                "sp_Promote_Vip_Scope_Insert",
                parameters,
                transaction);
            return (int)parameters.Find(parameter => parameter.ParameterName == "ReferenceID").Value;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 修改活动商品.
        /// </summary>
        /// <param name="promoteVipScope">
        /// 活动商品实体.
        /// </param>
        /// <param name="transaction">
        /// 数据事务.
        /// </param>
        public void Update(Promote_Vip_Scope promoteVipScope, SqlTransaction transaction)
        {
            if (promoteVipScope == null)
            {
                throw new ArgumentNullException("promoteVipScope");
            }

            var parameters = new List<SqlParameter>
                                 {
                                     this.SqlServer.CreateSqlParameter(
                                         "PromoteVipID",
                                         SqlDbType.Int,
                                         promoteVipScope.PromoteVipID,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "ProductID",
                                         SqlDbType.NVarChar,
                                         promoteVipScope.ProductID,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "ReferenceID",
                                         SqlDbType.Int,
                                         promoteVipScope.ID,
                                         ParameterDirection.Output)
                                 };

            this.SqlServer.ExecuteNonQuery(CommandType.StoredProcedure, "sp_Promote_Vip_Scope_Update", parameters, transaction);
        }