public object CreateSeat([FromBody] CreateSeatModel 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 = SeatServer.CreateSeat(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 CreateSeat(CreateSeatModel cm) { using (var con = new SqlConnection(Server.SqlConString)) { con.Open(); var sqlCom = new SqlCommand("sp_CreateSeat", con) { CommandType = CommandType.StoredProcedure }; sqlCom.Parameters.AddRange(new [] { new SqlParameter { ParameterName = "@theaterId", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int, Value = cm.theaterId }, new SqlParameter { ParameterName = "@rowNumber", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int, Value = cm.rowNumber }, new SqlParameter { ParameterName = "@colNumber", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int, Value = cm.colNumber }, 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 }); } }