public object UpdateTheater([FromBody] UpdateTheaterModel um) { 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.UpdateTheater(um); return(re); } catch (Exception e) { return(new { result = e.HResult, msg = e.Message }); } }
///<summary> /// 更新放映厅 /// </summary> /// <param name="cm">更新放映厅名称以及地理位置</param> /// <returns>更新结果</returns> public static object UpdateTheater(UpdateTheaterModel cm) { using (var con = new SqlConnection(Server.SqlConString)) { con.Open(); var sqlCom = new SqlCommand("sp_UpdateTheater", con) { CommandType = CommandType.StoredProcedure }; sqlCom.Parameters.AddRange(new [] { new SqlParameter { ParameterName = "@theaterId", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int, Value = cm.TheaterId }, new SqlParameter { ParameterName = "@theaterName", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.NVarChar, Size = 30, Value = cm.TheaterName }, new SqlParameter { ParameterName = "@theaterLocation", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.NVarChar, Size = 30, Value = cm.Location }, new SqlParameter { ParameterName = "@theaterMapSite", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.NVarChar, Size = 30, Value = cm.MapSite }, 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 }); } }