public CTrade BuyTrade(CTrade objCTrade, int GMTInfo) { using (SqlConnection cnn = new SqlConnection(CommonCollection.ConnectionString)) { try { cnn.Open(); using (SqlCommand cmd = new SqlCommand("BuyTrade", cnn)) { cmd.CommandType = CommandType.StoredProcedure; cmd.CommandTimeout = 60; cmd.Parameters.Add("@userId", SqlDbType.Int).Value = objCTrade.UserId; cmd.Parameters.Add("@TradeAmount", SqlDbType.Float).Value = objCTrade.TradeAmount; cmd.Parameters.Add("@SymbolID", SqlDbType.NVarChar).Value = objCTrade.SymbolId; cmd.Parameters.Add("@TradeType", SqlDbType.NVarChar).Value = objCTrade.TradeType; cmd.Parameters.Add("@PayOutPercentage", SqlDbType.Int).Value = objCTrade.PayoutPerCentage; cmd.Parameters.Add("@ExpiryTimeInterval", SqlDbType.Int).Value = objCTrade.ExpiryTimeInterval; cmd.Parameters.Add("@xpoints", SqlDbType.NVarChar).Value = objCTrade.xpoints; cmd.Parameters.Add("@ypoints", SqlDbType.NVarChar).Value = objCTrade.ypoints; cmd.Parameters.Add("@TradeWay", SqlDbType.NVarChar).Value = objCTrade.TradeWay; cmd.Parameters.Add("@idOut", SqlDbType.Int).Value = null; cmd.Parameters["@idOut"].Direction = ParameterDirection.Output; cmd.ExecuteNonQuery(); objCTrade.TradeId = Convert.ToInt32(cmd.Parameters["@idOut"].Value.ToString()); if (objCTrade.TradeId > 0) { StockModels objStockModels = new StockModels(); objStockModels.GetTradebyTradeId(objCTrade, GMTInfo, 0); } } } catch (Exception ex) { throw new Exception(ex.ToString(), ex); } finally { cnn.Close(); cnn.Dispose(); GC.Collect(); SqlConnection.ClearPool(cnn); } return objCTrade; } }
public ActionResult GetTradebyTradeId(Int32 TradeId, string ExpPrice) { CTrade objCTrade = new CTrade(); StockModels objStockModels = new StockModels(); Int32 UserId = Convert.ToInt32(Session["user"]); Int32 GmtInfo = Convert.ToInt32(Session["GMTInfo"]); try { if (UserId > -1) { objCTrade.TradeId = TradeId; objCTrade.UserId = UserId; objStockModels.TradeExpire(TradeId, ExpPrice); objCTrade = objStockModels.GetTradebyTradeId(objCTrade, GmtInfo, 1); ViewBag.IsClosed = 1; Session["TradeBalance"] = objStockModels.GetUserAccountBalance(UserId); ViewBag.IsClosed = 1; if (objCTrade.TradeId == 0) { return Json(objCTrade); } return PartialView("_SingleOpenTrade", objCTrade); } else { objCTrade.TradeId = -1; return Json(objCTrade); } } catch (Exception ex) { throw ex; } }