public static List <clsModelPortfolioDetails> replicatePortfolioDetails(List <clsPortfolioDetails> _clsPortfolioDetails)
        {
            List <clsModelPortfolioDetails> listModelPortfolioDetails = new List <clsModelPortfolioDetails>();
            float  fTotalAllocation = 0;
            double dPrice           = 0;
            string strIntegerPart   = string.Empty;
            double dConvertedValue  = 0;
            int    intMarker        = 0;

            foreach (clsPortfolioDetails PortfolioDetails in _clsPortfolioDetails)
            {
                clsModelPortfolioDetails _clsModelPortfolioDetails = new clsModelPortfolioDetails();
                _clsModelPortfolioDetails.propFund       = new clsFund(PortfolioDetails.propFundNameID);
                _clsModelPortfolioDetails.propAllocation = float.Parse(Math.Round(double.Parse(PortfolioDetails.propAllocationPercent.ToString()), 2).ToString());

                if (PortfolioDetails.propClientCurrency != PortfolioDetails.propFundCurrency)
                {
                    dConvertedValue = clsCurrency.convertToClientCurrency(_clsPortfolioDetails[0].propClientID, PortfolioDetails.propPrice, PortfolioDetails.propFundCurrency);
                    intMarker       = dConvertedValue.ToString().IndexOf('.');
                    strIntegerPart  = dConvertedValue.ToString().Substring(0, intMarker);

                    string strDecimalPart = dConvertedValue.ToString().Substring(intMarker, 4);
                    dPrice = Convert.ToDouble(strIntegerPart + strDecimalPart);
                }
                else
                {
                    dPrice = Math.Round(PortfolioDetails.propPrice, 4);
                }

                _clsModelPortfolioDetails.propCurrencyMultiplier = clsCurrency.getCurrencyMultiplier(_clsPortfolioDetails[0].propClientID, PortfolioDetails.propFundCurrency);
                _clsModelPortfolioDetails.propTotalValue         = float.Parse(Math.Round(double.Parse(PortfolioDetails.propTotalCurrentValueClient.ToString()), 0).ToString());

                fTotalAllocation = fTotalAllocation + _clsModelPortfolioDetails.propAllocation;
                _clsModelPortfolioDetails.propTotalAllocation = fTotalAllocation;
                _clsModelPortfolioDetails.propIsDeletable     = true;

                _clsModelPortfolioDetails.propValue = float.Parse(((Math.Round(_clsModelPortfolioDetails.propAllocation, 2) / 100) * int.Parse(PortfolioDetails.propTotalCurrentValueClient.ToString())).ToString());
                _clsModelPortfolioDetails.propUnits = Convert.ToDecimal((((Math.Round(_clsModelPortfolioDetails.propAllocation, 2) / 100) * int.Parse(PortfolioDetails.propTotalCurrentValueClient.ToString())) / dPrice));

                listModelPortfolioDetails.Add(_clsModelPortfolioDetails);
            }
            return(listModelPortfolioDetails);
        }
        public static List<clsModelPortfolioDetails> getModelPortfolioDetails(clsPortfolio Portfolio, int intModelID, string strModelGroupID, string strModolPortfolioID)
        {

            SqlConnection con = new clsSystem_DBConnection(clsSystem_DBConnection.strConnectionString.NavIntegrationDB).propConnection;
            List<clsModelPortfolioDetails> listModelPortfolioDetails = new List<clsModelPortfolioDetails>();

            SqlCommand cmd = new SqlCommand();
            SqlDataReader dr1;

            //con1.Open();
            con.Open();
            cmd.Connection = con;//con1;
            cmd.CommandType = System.Data.CommandType.StoredProcedure;
            cmd.CommandText = "[SWITCH_ModelPortfolioDetailsGet]";

            cmd.Parameters.Add("@param_ModelID", System.Data.SqlDbType.Int).Value = intModelID;
            cmd.Parameters.Add("@param_ModelGroupID", System.Data.SqlDbType.NVarChar).Value = strModelGroupID;
            cmd.Parameters.Add("@param_ModelPortfolioID", System.Data.SqlDbType.NVarChar).Value = strModolPortfolioID;

            dr1 = cmd.ExecuteReader();

            float fTotalAllocation = 0;

            while (dr1.Read())
            {

                clsModelPortfolioDetails ModelPortfolioDetails = new clsModelPortfolioDetails();

                ModelPortfolioDetails.propModelID = int.Parse(dr1["ModelID"].ToString());
                ModelPortfolioDetails.propAllocation = float.Parse(Math.Round(double.Parse(dr1["Allocation"].ToString()), 2).ToString());
                ModelPortfolioDetails.propFund = new clsFund(int.Parse(dr1["FundID"].ToString()));
                ModelPortfolioDetails.propFundID = int.Parse(dr1["FundID"].ToString());
                ModelPortfolioDetails.propIsDeletable = dr1["isDeletable"].ToString().Equals("1") ? true : false;

                if (Portfolio.propPortfolioDetails[0].propClientCurrency != ModelPortfolioDetails.propFund.propCurrency)
                {
                    ModelPortfolioDetails.propUnits = clsSwitchDetails.computeUnits(ModelPortfolioDetails.propAllocation,
                                                                                  float.Parse(Math.Round(double.Parse(Portfolio.propPortfolioDetails[0].propTotalCurrentValueClient.ToString()), 0).ToString()),
                                                                                  clsCurrency.convertToClientCurrency(strModelGroupID, ModelPortfolioDetails.propFund.propPrice, ModelPortfolioDetails.propFund.propCurrency));
                }
                else
                {
                    ModelPortfolioDetails.propUnits = clsSwitchDetails.computeUnits(ModelPortfolioDetails.propAllocation,
                                                                                  float.Parse(Math.Round(double.Parse(Portfolio.propPortfolioDetails[0].propTotalCurrentValueClient.ToString()), 0).ToString()),
                                                                                  ModelPortfolioDetails.propFund.propPrice);
                }


                ModelPortfolioDetails.propCurrencyMultiplier = clsCurrency.getCurrencyMultiplier(strModelGroupID, ModelPortfolioDetails.propFund.propCurrency);
                ModelPortfolioDetails.propTotalValue = float.Parse(Math.Round(double.Parse(Portfolio.propPortfolioDetails[0].propTotalCurrentValueClient.ToString()), 0).ToString());
                ModelPortfolioDetails.propValue = clsSwitchDetails.computeValue(ModelPortfolioDetails.propAllocation, ModelPortfolioDetails.propTotalValue);


                fTotalAllocation = fTotalAllocation + ModelPortfolioDetails.propAllocation;
                ModelPortfolioDetails.propTotalAllocation = fTotalAllocation;

                listModelPortfolioDetails.Add(ModelPortfolioDetails);

            }
            //con1.Close();
            con.Close();
            cmd.Dispose();
            //con1.Dispose();
            con.Dispose();

            return listModelPortfolioDetails;
        }
        public static List<clsModelPortfolioDetails> replicatePortfolioDetails(List<clsPortfolioDetails> _clsPortfolioDetails)
        {

            List<clsModelPortfolioDetails> listModelPortfolioDetails = new List<clsModelPortfolioDetails>();
            float fTotalAllocation = 0;
            double dPrice = 0;
            string strIntegerPart = string.Empty;
            double dConvertedValue = 0;
            int intMarker = 0;
            foreach (clsPortfolioDetails PortfolioDetails in _clsPortfolioDetails)
            {
                clsModelPortfolioDetails _clsModelPortfolioDetails = new clsModelPortfolioDetails();
                _clsModelPortfolioDetails.propFund = new clsFund(PortfolioDetails.propFundNameID);
                _clsModelPortfolioDetails.propAllocation = float.Parse(Math.Round(double.Parse(PortfolioDetails.propAllocationPercent.ToString()), 2).ToString());

                if (PortfolioDetails.propClientCurrency != PortfolioDetails.propFundCurrency)
                {
                    dConvertedValue = clsCurrency.convertToClientCurrency(_clsPortfolioDetails[0].propClientID, PortfolioDetails.propPrice, PortfolioDetails.propFundCurrency);
                    intMarker = dConvertedValue.ToString().IndexOf('.');
                    strIntegerPart = dConvertedValue.ToString().Substring(0, intMarker);

                    string strDecimalPart = dConvertedValue.ToString().Substring(intMarker, 4);
                    dPrice = Convert.ToDouble(strIntegerPart + strDecimalPart);
                }
                else
                {
                    dPrice = Math.Round(PortfolioDetails.propPrice, 4);
                }

                _clsModelPortfolioDetails.propCurrencyMultiplier = clsCurrency.getCurrencyMultiplier(_clsPortfolioDetails[0].propClientID, PortfolioDetails.propFundCurrency);
                _clsModelPortfolioDetails.propTotalValue = float.Parse(Math.Round(double.Parse(PortfolioDetails.propTotalCurrentValueClient.ToString()), 0).ToString());

                fTotalAllocation = fTotalAllocation + _clsModelPortfolioDetails.propAllocation;
                _clsModelPortfolioDetails.propTotalAllocation = fTotalAllocation;
                _clsModelPortfolioDetails.propIsDeletable = true;

                _clsModelPortfolioDetails.propValue = float.Parse(((Math.Round(_clsModelPortfolioDetails.propAllocation, 2) / 100) * int.Parse(PortfolioDetails.propTotalCurrentValueClient.ToString())).ToString());
                _clsModelPortfolioDetails.propUnits = Convert.ToDecimal((((Math.Round(_clsModelPortfolioDetails.propAllocation, 2) / 100) * int.Parse(PortfolioDetails.propTotalCurrentValueClient.ToString())) / dPrice));

                listModelPortfolioDetails.Add(_clsModelPortfolioDetails);
            }
            return listModelPortfolioDetails;
        }
        public static List <clsModelPortfolioDetails> getModelPortfolioDetails(clsPortfolio Portfolio, int intModelID, string strModelGroupID, string strModolPortfolioID)
        {
            SqlConnection con = new clsSystem_DBConnection(clsSystem_DBConnection.strConnectionString.NavIntegrationDB).propConnection;
            List <clsModelPortfolioDetails> listModelPortfolioDetails = new List <clsModelPortfolioDetails>();

            SqlCommand    cmd = new SqlCommand();
            SqlDataReader dr1;

            //con1.Open();
            con.Open();
            cmd.Connection  = con;//con1;
            cmd.CommandType = System.Data.CommandType.StoredProcedure;
            cmd.CommandText = "[SWITCH_ModelPortfolioDetailsGet]";

            cmd.Parameters.Add("@param_ModelID", System.Data.SqlDbType.Int).Value               = intModelID;
            cmd.Parameters.Add("@param_ModelGroupID", System.Data.SqlDbType.NVarChar).Value     = strModelGroupID;
            cmd.Parameters.Add("@param_ModelPortfolioID", System.Data.SqlDbType.NVarChar).Value = strModolPortfolioID;

            dr1 = cmd.ExecuteReader();

            float fTotalAllocation = 0;

            while (dr1.Read())
            {
                clsModelPortfolioDetails ModelPortfolioDetails = new clsModelPortfolioDetails();

                ModelPortfolioDetails.propModelID     = int.Parse(dr1["ModelID"].ToString());
                ModelPortfolioDetails.propAllocation  = float.Parse(Math.Round(double.Parse(dr1["Allocation"].ToString()), 2).ToString());
                ModelPortfolioDetails.propFund        = new clsFund(int.Parse(dr1["FundID"].ToString()));
                ModelPortfolioDetails.propFundID      = int.Parse(dr1["FundID"].ToString());
                ModelPortfolioDetails.propIsDeletable = dr1["isDeletable"].ToString().Equals("1") ? true : false;

                if (Portfolio.propPortfolioDetails[0].propClientCurrency != ModelPortfolioDetails.propFund.propCurrency)
                {
                    ModelPortfolioDetails.propUnits = clsSwitchDetails.computeUnits(ModelPortfolioDetails.propAllocation,
                                                                                    float.Parse(Math.Round(double.Parse(Portfolio.propPortfolioDetails[0].propTotalCurrentValueClient.ToString()), 0).ToString()),
                                                                                    clsCurrency.convertToClientCurrency(strModelGroupID, ModelPortfolioDetails.propFund.propPrice, ModelPortfolioDetails.propFund.propCurrency));
                }
                else
                {
                    ModelPortfolioDetails.propUnits = clsSwitchDetails.computeUnits(ModelPortfolioDetails.propAllocation,
                                                                                    float.Parse(Math.Round(double.Parse(Portfolio.propPortfolioDetails[0].propTotalCurrentValueClient.ToString()), 0).ToString()),
                                                                                    ModelPortfolioDetails.propFund.propPrice);
                }


                ModelPortfolioDetails.propCurrencyMultiplier = clsCurrency.getCurrencyMultiplier(strModelGroupID, ModelPortfolioDetails.propFund.propCurrency);
                ModelPortfolioDetails.propTotalValue         = float.Parse(Math.Round(double.Parse(Portfolio.propPortfolioDetails[0].propTotalCurrentValueClient.ToString()), 0).ToString());
                ModelPortfolioDetails.propValue = clsSwitchDetails.computeValue(ModelPortfolioDetails.propAllocation, ModelPortfolioDetails.propTotalValue);


                fTotalAllocation = fTotalAllocation + ModelPortfolioDetails.propAllocation;
                ModelPortfolioDetails.propTotalAllocation = fTotalAllocation;

                listModelPortfolioDetails.Add(ModelPortfolioDetails);
            }
            //con1.Close();
            con.Close();
            cmd.Dispose();
            //con1.Dispose();
            con.Dispose();

            return(listModelPortfolioDetails);
        }