public object SelectGood([FromBody] SelectGoodModel sgm) { 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.SelectGood(sgm); return(re); } catch (Exception e) { return(new { result = e.HResult, msg = e.Message }); } }
/// <summary> /// 筛选上架商品(包含影厅名称) /// </summary> /// <returns></returns> public static object SelectGoodWithName(SelectGoodModel sgm) { using (var con = new SqlConnection(Server.SqlConString)) { con.Open(); var message = ""; var sqlCom = new SqlCommand("sp_SelectGoodWithName", con) { CommandType = CommandType.StoredProcedure }; sqlCom.Parameters.AddRange(new[] { new SqlParameter { ParameterName = "@theaterId", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int, Value = sgm.TheaterId }, new SqlParameter { ParameterName = "@programmeId", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int, Value = sgm.ProgrammeId }, new SqlParameter { ParameterName = "@playDate", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Date, Value = sgm.PlayDate }, new SqlParameter { ParameterName = "@performance", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.NVarChar, Size = 10, Value = sgm.Performance }, new SqlParameter { ParameterName = "@message", Direction = ParameterDirection.Output, Size = 30, SqlDbType = SqlDbType.VarChar, Value = message }, new SqlParameter { ParameterName = "@return", Direction = ParameterDirection.ReturnValue, SqlDbType = SqlDbType.Int } }); sqlCom.ExecuteNonQuery(); var msg = (string)sqlCom.Parameters["@message"].Value; var data = new List <object>(); var reader = sqlCom.ExecuteReader(); while (reader.Read()) { data.Add(new { goodId = (int)reader[0], programmeId = (int)reader[1], theaterId = (int)reader[2], performance = (string)reader[3], playDate = (DateTime)reader[4], price = (decimal)reader[5], theaterName = (string)reader[6], programmeImagePath = (string)reader[7], programmeName = (string)reader[8], duration = (int)reader[9] }); } return(new { result = (int)sqlCom.Parameters["@return"].Value, msg, data }); } }