/// <summary>
        /// This method returns partner name based on userIDs
        /// </summary>
        /// <param name="userID">userID</param>
        /// <returns></returns>
        public string GetPartnerName(int userID)
        {
            try
            {
                using (var unitOfWork = new EFUnitOfWork())
                {
                    var introducingBrokerRepo =
                        new IntroducingBrokerRepository(new EFRepository <IntroducingBroker>(), unitOfWork);


                    ObjectSet <IntroducingBroker> introducingBrokerObjSet =
                        ((CurrentDeskClientsEntities)introducingBrokerRepo.Repository.UnitOfWork.Context).IntroducingBrokers;

                    //Get The Selected tunning and assign its Properties.
                    var selectedIB =
                        introducingBrokerObjSet.Where(ib => ib.FK_UserID == userID).FirstOrDefault();

                    //Check for nullability
                    if (selectedIB != null)
                    {
                        //Get account type details
                        var accTypeBO          = new AccountTypeBO();
                        var accountTypeDetails = accTypeBO.GetAccountTypeAndFormTypeValue((int)selectedIB.FK_AccountTypeID);

                        if (accountTypeDetails.FK_AccountTypeValue == Constants.K_ACCT_INDIVIDUAL)
                        {
                            var individualAccountBO = new IndividualAccountInformationBO();
                            return(individualAccountBO.GetPartnerIndividualName(selectedIB.PK_IntroducingBrokerID));
                        }
                        else if (accountTypeDetails.FK_AccountTypeValue == Constants.K_ACCT_JOINT)
                        {
                            var jointAccountBO = new JointAccountInformationBO();
                            return(jointAccountBO.GetPartnerIndividualName(selectedIB.PK_IntroducingBrokerID));
                        }
                        else if (accountTypeDetails.FK_AccountTypeValue == Constants.K_ACCT_CORPORATE)
                        {
                            var corporateAccountBO = new CorporateAccountInformationBO();
                            return(corporateAccountBO.GetPartnerIndividualName(selectedIB.PK_IntroducingBrokerID));
                        }
                        else if (accountTypeDetails.FK_AccountTypeValue == Constants.K_ACCT_TRUST)
                        {
                            var trustAccountBO = new TrustAccountInformationBO();
                            return(trustAccountBO.GetPartnerIndividualName(selectedIB.PK_IntroducingBrokerID));
                        }
                    }

                    return(String.Empty);
                }
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                return(String.Empty);
            }
        }
        /// <summary>
        /// This method returns list of partner names and userID
        /// </summary>
        /// <param name="userID">users</param>
        /// <returns></returns>
        public List <BrokerClients> GetPartnerNames(List <User> users, int accountNumberPosition)
        {
            try
            {
                //Get all userids
                var listOfUsersID = users.Select(x => x.PK_UserID).ToList();

                using (var unitOfWork = new EFUnitOfWork())
                {
                    var ibRepo =
                        new IntroducingBrokerRepository(new EFRepository <IntroducingBroker>(), unitOfWork);

                    var context =
                        ((CurrentDeskClientsEntities)ibRepo.Repository.UnitOfWork.Context);

                    //Get the selected client and assign its Properties.
                    var selectedClient =
                        context.IntroducingBrokers.Where(brk => listOfUsersID.Contains((int)brk.FK_UserID))
                        .Include("IndividualAccountInformations")
                        .Include("JointAccountInformations")
                        .Include("CorporateAccountInformations")
                        .Include("TrustAccountInformations")
                        .Include("Client_Account")
                        .ToList();


                    List <BrokerClients> lstBrokerClients = new List <BrokerClients>();

                    //Check for nullability
                    if (selectedClient != null)
                    {
                        foreach (var item in selectedClient)
                        {
                            var    brokerClient = new BrokerClients();
                            string brokerName   = string.Empty;

                            //Get account type details
                            var accTypeBO          = new AccountTypeBO();
                            var accountTypeDetails = accTypeBO.GetAccountTypeAndFormTypeValue((int)item.FK_AccountTypeID);

                            if (accountTypeDetails.FK_AccountTypeValue == Constants.K_ACCT_INDIVIDUAL)
                            {
                                var liveInfo = item.IndividualAccountInformations.FirstOrDefault();
                                brokerName = (liveInfo != null ? liveInfo.FirstName + " " + liveInfo.LastName : null) + " - " + (item.Client_Account.FirstOrDefault() != null ? item.Client_Account.FirstOrDefault().LandingAccount.Split('-')[accountNumberPosition] : "");
                            }
                            else if (accountTypeDetails.FK_AccountTypeValue == Constants.K_ACCT_JOINT)
                            {
                                var jointInfo = item.JointAccountInformations.FirstOrDefault();
                                brokerName = (jointInfo != null ? jointInfo.PrimaryAccountHolderFirstName + " " + jointInfo.PrimaryAccountHolderLastName : null) + " - " + (item.Client_Account.FirstOrDefault() != null ? item.Client_Account.FirstOrDefault().LandingAccount.Split('-')[accountNumberPosition] : "");
                            }
                            else if (accountTypeDetails.FK_AccountTypeValue == Constants.K_ACCT_CORPORATE)
                            {
                                var corInfo = item.CorporateAccountInformations.FirstOrDefault();
                                brokerName = (corInfo != null ? corInfo.CompanyName : null) + " - " + (item.Client_Account.FirstOrDefault() != null ? item.Client_Account.FirstOrDefault().LandingAccount.Split('-')[accountNumberPosition] : "");
                            }
                            else if (accountTypeDetails.FK_AccountTypeValue == Constants.K_ACCT_TRUST)
                            {
                                var trustInfo = item.TrustAccountInformations.FirstOrDefault();
                                brokerName = (trustInfo != null ? trustInfo.TrustName : null) + " - " + (item.Client_Account.FirstOrDefault() != null ? item.Client_Account.FirstOrDefault().LandingAccount.Split('-')[accountNumberPosition] : "");
                            }

                            brokerClient.UserID      = (int)item.FK_UserID;
                            brokerClient.DisplayName = brokerName;

                            //Add to list
                            lstBrokerClients.Add(brokerClient);
                        }
                    }

                    return(lstBrokerClients);
                }
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }