public object CreateTheater([FromBody] CreateTheaterModel 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 = TheaterServer.CreateTheater(cm);

                return(re);
            }
            catch (Exception e)
            {
                return(new
                {
                    result = e.HResult,
                    msg = e.Message
                });
            }
        }
Beispiel #2
0
        /// <summary>
        /// 创建一个新演出厅
        /// </summary>
        /// <param name="cm">演出厅信息</param>
        /// <returns>创建结果</returns>
        public static object CreateTheater(CreateTheaterModel cm)
        {
            using (var con = new SqlConnection(Server.SqlConString))
            {
                con.Open();

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

                sqlCom.Parameters.AddRange(new[]
                {
                    new SqlParameter
                    {
                        ParameterName = "@theaterName",
                        Direction     = ParameterDirection.Input,
                        SqlDbType     = SqlDbType.NVarChar,
                        Size          = 30,
                        Value         = cm.TheaterName
                    },
                    new SqlParameter
                    {
                        ParameterName = "@Location",
                        Direction     = ParameterDirection.Input,
                        SqlDbType     = SqlDbType.NVarChar,
                        Size          = 30,
                        Value         = cm.Location
                    },
                    new SqlParameter
                    {
                        ParameterName = "@MapSite",
                        Direction     = ParameterDirection.Input,
                        SqlDbType     = SqlDbType.NVarChar,
                        Size          = 30,
                        Value         = cm.MapSite
                    },
                    new SqlParameter
                    {
                        ParameterName = "@seatRowsCount",
                        Direction     = ParameterDirection.Input,
                        SqlDbType     = SqlDbType.Int,
                        Value         = cm.SeatRowCount
                    },
                    new SqlParameter
                    {
                        ParameterName = "@seatColsCount",
                        Direction     = ParameterDirection.Input,
                        SqlDbType     = SqlDbType.Int,
                        Value         = cm.SeatColCount
                    },
                    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
                });
            }
        }