Esempio n. 1
0
        public object UpdateGood([FromBody] UpdateGoodModel cm)
        {
            try
            {
//                var addr = Server.GetUserIp(Request.HttpContext);
//                if (Server.IpHandle(addr) == 0)
//                {
//                    return new[] { "your ip can't using our api , please contact administrator" };
//                }
//
                var account = HttpContext.Session.GetString("user_account");

                if (account == null)
                {
                    return(new
                    {
                        result = 401,
                        msg = "not login"
                    });
                }

                var re = GoodServer.UpdateGood(cm);

                return(re);
            }
            catch (Exception e)
            {
                return(new
                {
                    result = e.HResult,
                    msg = e.Message
                });
            }
        }
        ///<summary>
        /// 更新演出计划
        /// </summary>
        /// <param name="cm">更新演出计划模型</param>

        /// <returns>更新结果</returns>
        public static object UpdateGood(UpdateGoodModel cm)
        {
            using (var con = new SqlConnection(Server.SqlConString))
            {
                con.Open();

                var sqlCom = new SqlCommand("sp_UpdateGood", con)
                {
                    CommandType = CommandType.StoredProcedure
                };

                sqlCom.Parameters.AddRange(new []
                {
                    new SqlParameter
                    {
                        ParameterName = "@goodId",
                        Direction     = ParameterDirection.Input,
                        SqlDbType     = SqlDbType.Int,
                        Value         = cm.GoodId
                    },
                    new SqlParameter
                    {
                        ParameterName = "@programmeId",
                        Direction     = ParameterDirection.Input,
                        SqlDbType     = SqlDbType.Int,
                        Value         = cm.ProgrammeId
                    },
                    new SqlParameter
                    {
                        ParameterName = "@theaterId",
                        Direction     = ParameterDirection.Input,
                        SqlDbType     = SqlDbType.Int,
                        Value         = cm.TheaterId
                    },
                    new SqlParameter
                    {
                        ParameterName = "@performance",
                        Direction     = ParameterDirection.Input,
                        Size          = 10,
                        SqlDbType     = SqlDbType.VarChar,
                        Value         = cm.Performance
                    },
                    new SqlParameter
                    {
                        ParameterName = "@playDate",
                        Direction     = ParameterDirection.Input,
                        SqlDbType     = SqlDbType.Date,
                        Value         = cm.PlayDate
                    },
                    new SqlParameter
                    {
                        ParameterName = "@price",
                        Direction     = ParameterDirection.Input,
                        SqlDbType     = SqlDbType.Int,
                        Value         = cm.Price
                    },
                    new SqlParameter
                    {
                        ParameterName = "@message",
                        Direction     = ParameterDirection.Output,
                        Size          = 30,
                        SqlDbType     = SqlDbType.VarChar
                    },
                    new SqlParameter
                    {
                        ParameterName = "@return",
                        Direction     = ParameterDirection.ReturnValue,
                        SqlDbType     = SqlDbType.Int
                    }
                });

                sqlCom.ExecuteNonQuery();

                return(new
                {
                    result = (int)sqlCom.Parameters["@return"].Value,
                    msg = (string)sqlCom.Parameters["@message"].Value
                });
            }
        }