/// <summary>
        /// Created By : Satish Verma
        /// Created Date : 18-Dec-2014
        /// Purpose : To get trading history by user
        /// </summary>
        /// <param name="objTradingHistoryBO"></param>
        /// <returns></returns>
        public DataTable GetTradingHistoryByUserId(TradingHistoryBO objTradingHistoryBO)
        {
            DataTable objDataTable = new DataTable();

            try
            {
                sqlConnection.Open();
                sqlCommand             = new SqlCommand();
                sqlCommand.Connection  = sqlConnection;
                sqlCommand.CommandText = "Sp_GetTradingHistoryByUserId";
                sqlCommand.CommandType = CommandType.StoredProcedure;
                sqlCommand.Parameters.AddWithValue("@UserId", objTradingHistoryBO.UserId);
                sqlCommand.Parameters.AddWithValue("@PageNumber", objTradingHistoryBO.PageNumber);
                sqlCommand.Parameters.AddWithValue("@PageSize", objTradingHistoryBO.PageSize);
                sqlCommand.Parameters.AddWithValue("@Sort", objTradingHistoryBO.Sort);
                sqlCommand.Parameters.AddWithValue("@SearchText", objTradingHistoryBO.SearchText);
                sqlCommand.Parameters.AddWithValue("@FromDate", objTradingHistoryBO.FromDate);
                sqlCommand.Parameters.AddWithValue("@ToDate", objTradingHistoryBO.ToDate);
                sqlDataAdapter = new SqlDataAdapter(sqlCommand);
                sqlDataAdapter.Fill(objDataTable);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                sqlDataAdapter.Dispose();
                sqlCommand.Dispose();
                sqlConnection.Close();
                sqlConnection.Dispose();
            }
            return(objDataTable);
        }
        public List <TradingHistoryBO> GetTradingHistoryByUserId(string userId, string pageNumber, string pageSize, string sort, string searchText, string fromDate, string toDate)
        {
            try
            {
                if (string.IsNullOrEmpty(pageNumber))
                {
                    pageNumber = "0";
                }

                if (string.IsNullOrEmpty(pageSize))
                {
                    pageSize = "0";
                }

                TradingHistoryBO objTradingHistoryBO = new TradingHistoryBO();
                objTradingHistoryBO.PageNumber = Convert.ToInt32(pageNumber);
                objTradingHistoryBO.PageSize   = Convert.ToInt32(pageSize);
                objTradingHistoryBO.Sort       = sort;
                objTradingHistoryBO.SearchText = searchText;
                if (!string.IsNullOrEmpty(fromDate))
                {
                    objTradingHistoryBO.FromDate = Convert.ToDateTime(fromDate).ToString("yyyy-MM-dd"); //fromDate;
                }
                else
                {
                    objTradingHistoryBO.FromDate = string.Empty;
                }

                if (!string.IsNullOrEmpty(toDate))
                {
                    objTradingHistoryBO.ToDate = Convert.ToDateTime(toDate).ToString("yyyy-MM-dd");  //toDate;
                }
                else
                {
                    objTradingHistoryBO.ToDate = string.Empty;
                }

                List <TradingHistoryBO> lstTradingHistoryBO = new List <TradingHistoryBO>();
                if (!string.IsNullOrEmpty(Convert.ToString(HttpContext.Current.Session["UserIdToViewTradingHistory"])))
                {
                    objTradingHistoryBO.UserId = new Guid(Convert.ToString(HttpContext.Current.Session["UserIdToViewTradingHistory"]));

                    //Guid id = new Guid(Convert.ToString(userId));
                    lstTradingHistoryBO = new UserManagementBL().GetTradingHistoryByUserId(objTradingHistoryBO);
                }
                return(lstTradingHistoryBO);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// Created By : Satish Verma
        /// Created Date : 18-Dec-2014
        /// Purpose : To get trading history by user
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public List <TradingHistoryBO> GetTradingHistoryByUserId(TradingHistoryBO obTradingHistoryBO)
        {
            DataTable objDataTable = new UserManagementDA().GetTradingHistoryByUserId(obTradingHistoryBO);
            List <TradingHistoryBO> lstTradingHistoryBO = new List <TradingHistoryBO>();

            foreach (DataRow Row in objDataTable.Rows)
            {
                TradingHistoryBO objTradingHistoryBO = new TradingHistoryBO();
                objTradingHistoryBO.TradingHistoryId = Convert.ToInt64(Row["TradingHistoryId"]);
                objTradingHistoryBO.TradingTypeId    = Convert.ToInt32(Row["TradingTypeId"]);

                if (string.IsNullOrEmpty(Convert.ToString(Row["TradingType"])))
                {
                    objTradingHistoryBO.TradingType = string.Empty;
                }
                else
                {
                    objTradingHistoryBO.TradingType = Convert.ToString(Row["TradingType"]);
                }

                objTradingHistoryBO.BidType = Convert.ToString(Row["BidType"]);
                objTradingHistoryBO.AssetId = (Guid)Row["AssetId"];
                objTradingHistoryBO.Asset   = Convert.ToString(Row["Asset"]);

                if (string.IsNullOrEmpty(Convert.ToString(Row["InvestedAmount"])))
                {
                    objTradingHistoryBO.InvestedAmount = string.Empty;
                }
                else
                {
                    objTradingHistoryBO.InvestedAmount = Convert.ToString(Row["InvestedAmount"]);
                }

                if (string.IsNullOrEmpty(Convert.ToString(Row["Payout"])))
                {
                    //  objTradingHistoryBO.Payout = string.Empty;
                    objTradingHistoryBO.Payout = "0";
                }
                else
                {
                    objTradingHistoryBO.Payout = Convert.ToString(Row["Payout"]);
                }

                if (string.IsNullOrEmpty(Convert.ToString(Row["TargetPrice"])))
                {
                    objTradingHistoryBO.TargetPrice = string.Empty;
                }
                else
                {
                    objTradingHistoryBO.TargetPrice = Convert.ToString(Row["TargetPrice"]);
                }

                objTradingHistoryBO.TradeTime = Convert.ToDateTime(Row["TradeTime"]).ToString("HH:mm:ss");

                if (string.IsNullOrEmpty(Convert.ToString(Row["ExpiryPrice"])))
                {
                    objTradingHistoryBO.ExpiryPrice = string.Empty;
                }
                else
                {
                    objTradingHistoryBO.ExpiryPrice = Convert.ToString(Row["ExpiryPrice"]);
                }

                objTradingHistoryBO.ExpiryTime = Convert.ToDateTime(Row["ExpiryTime"]).ToString("HH:mm:ss");

                if (string.IsNullOrEmpty(Convert.ToString(Row["ExpirtyStatus"])))
                {
                    objTradingHistoryBO.ExpirtyStatus = null;
                }
                else
                {
                    objTradingHistoryBO.ExpirtyStatus = Convert.ToInt32(Row["ExpirtyStatus"]);
                }

                objTradingHistoryBO.ExpirtyStatusName = Convert.ToString(Row["ExpirtyStatusName"]);

                if (string.IsNullOrEmpty(Convert.ToString(Row["TradingStatus"])))
                {
                    objTradingHistoryBO.TradingStatus = null;
                }
                else
                {
                    objTradingHistoryBO.TradingStatus = Convert.ToInt32(Row["TradingStatus"]);
                }

                if (string.IsNullOrEmpty(Convert.ToString(Row["ReturnAmount"])))
                {
                    objTradingHistoryBO.ReturnAmount = string.Empty;
                }
                else
                {
                    objTradingHistoryBO.ReturnAmount = Convert.ToString(Row["ReturnAmount"]);
                }

                objTradingHistoryBO.UserId = (Guid)Row["UserId"];
                objTradingHistoryBO.IsRead = Convert.ToBoolean(Row["IsRead"]);
                objTradingHistoryBO.Total  = Convert.ToInt32(Row["Total"]);
                lstTradingHistoryBO.Add(objTradingHistoryBO);
            }
            return(lstTradingHistoryBO);
        }