/// <summary>
        /// This method returns all bank accounts for a particular user
        /// </summary>
        /// <param name="accType">accType</param>
        /// <param name="userID">userID</param>
        /// <returns></returns>
        public List <BankAccountInformation> GetAllBankInfosForUser(LoginAccountType accType, int userID)
        {
            try
            {
                using (var unitOfWork = new EFUnitOfWork())
                {
                    var bankRepo            = new BankAccountInformationRepository(new EFRepository <BankAccountInformation>(), unitOfWork);
                    var clientBO            = new ClientBO();
                    var introducingBrokerBO = new IntroducingBrokerBO();

                    ObjectSet <BankAccountInformation> bankAccountInformationObjSet =
                        ((CurrentDeskClientsEntities)bankRepo.Repository.UnitOfWork.Context).BankAccountInformations;

                    //Live
                    if (accType == LoginAccountType.LiveAccount)
                    {
                        var clientInformation = clientBO.GetClientInformation(userID);
                        return(bankAccountInformationObjSet.Where(clnt => clnt.FK_ClientID == clientInformation.PK_ClientID).ToList());
                    }
                    //Partner
                    else
                    {
                        var partnerInformation = introducingBrokerBO.GetClientInformation(userID);
                        return(bankAccountInformationObjSet.Where(part => part.FK_IntroducingBrokerID == partnerInformation.PK_IntroducingBrokerID).ToList());
                    }
                }
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
示例#2
0
        /// <summary>
        /// Function to make entry in database for uploaded document
        /// </summary>
        /// <param name="userID">userID</param>
        /// <param name="docID">docID</param>
        /// <param name="docName">docName</param>
        /// <returns></returns>
        public bool UploadDocument(int userID, int docID, string docName)
        {
            try
            {
                using (var unitOfWork = new EFUnitOfWork())
                {
                    var userDocRepo =
                        new UserDocumentRepository(new EFRepository <UserDocument>(), unitOfWork);

                    UserDocument doc = new UserDocument();
                    doc.UserDocumentName = docName;
                    doc.FK_DocumentID    = docID;
                    doc.Status           = "Pending";
                    doc.FK_UserID        = userID;
                    doc.IsDeleted        = false;

                    userDocRepo.Add(doc);
                    userDocRepo.Save();

                    return(true);
                }
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                return(false);
            }
        }
        /// <summary>
        /// This Function Will Get the name of selected
        /// Trading Experience depending upon tradingExperienceID
        /// </summary>
        /// <param name="tradingExperienceID"></param>
        /// <returns></returns>
        public string GetSelectedTradingExperience(int tradingExperienceID)
        {
            try
            {
                return(GetTradingExpValues().Where(trEx => trEx.PK_ExperienceID == tradingExperienceID).
                       Select(trEx => trEx.Experience).SingleOrDefault());

                //using (var unitOfWork = new EFUnitOfWork())
                //{
                //    var tradingExperienceRepo =
                //        new L_TradingExperienceRepository(new EFRepository<L_TradingExperience>(), unitOfWork);

                //    //Creating Country Objeset to Query
                //    ObjectSet<L_TradingExperience> tradingExpObjSet =
                //      ((CurrentDeskClientsEntities)tradingExperienceRepo.Repository.UnitOfWork.Context).L_TradingExperience;

                //    //Return the selected string
                //    return tradingExpObjSet.Where(trEx => trEx.PK_ExperienceID == tradingExperienceID).
                //        Select(trEx => trEx.Experience).SingleOrDefault();
                //}
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
        // Add your own data access methods here.  If you wish to
        // expose your public method to a WCF service, marked them with
        // the attribute [NCPublish], and another T4 template will generate your service contract

        /// <summary>
        /// This Function Will Get The Organization ID
        /// from the given URL
        /// </summary>
        /// <param name="url">URL</param>
        /// <returns>Organization ID</returns>
        public int?GetOrganizationIDFromURL(string url)
        {
            try
            {
                using (var unitOfWork = new EFUnitOfWork())
                {
                    var organizationRepo = new OrganizationRepository(new EFRepository <Organization>(), unitOfWork);
                    var OrganizationList = ((CurrentDeskClientsEntities)organizationRepo.Repository.UnitOfWork.Context).
                                           Organizations.ToList();

                    //Loop Through The Organization List
                    //And Match With Respective URL
                    foreach (var item in OrganizationList)
                    {
                        if (url.ToLower().Contains(item.OrganizationKey))
                        {
                            return(item.PK_OrganizationID);
                        }
                    }
                }

                return(null);
            }
            catch (Exception exceptionMessage)
            {
                CommonErrorLogger.CommonErrorLog(exceptionMessage, System.Reflection.MethodBase.GetCurrentMethod().Name);
                return(null);
            }
        }
        /// <summary>
        /// This method delete a transaction
        /// </summary>
        /// <param name="transactionID">transactionID</param>
        /// <returns></returns>
        public bool DeleteTransaction(int transactionID)
        {
            try
            {
                using (var unitOfWork = new EFUnitOfWork())
                {
                    var adminTransactionRepo =
                        new AdminTransactionRepository(new EFRepository <AdminTransaction>(), unitOfWork);

                    ObjectSet <AdminTransaction> transactionObjSet =
                        ((CurrentDeskClientsEntities)adminTransactionRepo.Repository.UnitOfWork.Context).AdminTransactions;

                    //Get particular transaction
                    var transaction = transactionObjSet.Where(tran => tran.PK_TransactionID == transactionID).FirstOrDefault();

                    //Set IsDeleted true and save
                    if (transaction != null)
                    {
                        transaction.IsDeleted = true;
                        adminTransactionRepo.Save();
                        return(true);
                    }

                    return(false);
                }
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
        /// <summary>
        /// This method returns false if referral link already exists
        /// </summary>
        /// <param name="referralLink">referralLink</param>
        /// <param name="organizationID">organizationID</param>
        /// <returns></returns>
        public bool CheckDuplicateReferralLink(string referralLink, int organizationID)
        {
            try
            {
                using (var unitOfWork = new EFUnitOfWork())
                {
                    var ibRepo =
                        new IntroducingBrokerRepository(new EFRepository <IntroducingBroker>(), unitOfWork);

                    ObjectSet <IntroducingBroker> ibObjSet =
                        ((CurrentDeskClientsEntities)ibRepo.Repository.UnitOfWork.Context).IntroducingBrokers;

                    var linkExists = ibObjSet.Where(link => link.CustomizedLink == referralLink && link.FK_OrganizationID == organizationID).ToList();
                    if (linkExists.Count() > 0)
                    {
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
        /// <summary>
        /// This Function will Return All Trustee Type
        /// </summary>
        /// <returns></returns>
        public List <L_CompanyTypeValue> GetCompanyType()
        {
            try
            {
                var companyTypeKey  = CacheKey.CDS_COMPANYTYPE;
                var companyTypeList = new List <L_CompanyTypeValue>();

                if (StaticCache.Exist(companyTypeKey))
                {
                    companyTypeList = (List <L_CompanyTypeValue>)StaticCache.Get(companyTypeKey);
                }
                else
                {
                    using (var unitOfWork = new EFUnitOfWork())
                    {
                        var lCompanyTypeRepo =
                            new L_CompanyTypeValueRepository(new EFRepository <L_CompanyTypeValue>(), unitOfWork);

                        //Returning List Of Demo Lead
                        companyTypeList = lCompanyTypeRepo.All().ToList();

                        //Store it into the cache
                        StaticCache.Max(companyTypeKey, companyTypeList);
                    }
                }

                return(companyTypeList);
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
示例#8
0
        /// <summary>
        /// This method enables a funding source
        /// </summary>
        /// <param name="fundSourceID">fundSourceID</param>
        /// <returns></returns>
        public bool EnableFundingSource(int fundSourceID)
        {
            try
            {
                using (var unitOfWork = new EFUnitOfWork())
                {
                    var fundSourceRepo =
                        new FundingSourceRepository(new EFRepository <FundingSource>(), unitOfWork);

                    ObjectSet <FundingSource> fundSourceObjSet =
                        ((CurrentDeskClientsEntities)fundSourceRepo.Repository.UnitOfWork.Context).FundingSources;

                    //Get particular funding source
                    var selectedFundSource = fundSourceObjSet.Where(fnd => fnd.PK_FundingSourceID == fundSourceID).FirstOrDefault();

                    //Set IsEnabled true
                    if (selectedFundSource != null)
                    {
                        selectedFundSource.IsEnabled = true;
                        fundSourceRepo.Save();
                        return(true);
                    }

                    return(false);
                }
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                return(false);
            }
        }
示例#9
0
        /// <summary>
        /// This method sets IsRead value of a message to true
        /// </summary>
        /// <param name="msgID">msgID</param>
        public void SetMessageIsReadTrue(int msgID)
        {
            try
            {
                using (var unitOfWork = new EFUnitOfWork())
                {
                    var userMsgRepo =
                        new InternalUserMessageRepository(new EFRepository <InternalUserMessage>(), unitOfWork);

                    ObjectSet <InternalUserMessage> userMsgObjSet =
                        ((CurrentDeskClientsEntities)userMsgRepo.Repository.UnitOfWork.Context).InternalUserMessages;

                    //Get that particular msg
                    var selectedMsg = userMsgObjSet.Where(msg => msg.PK_MessageID == msgID).FirstOrDefault();

                    if (selectedMsg != null)
                    {
                        selectedMsg.IsRead = true;
                        userMsgRepo.Save();
                    }
                }
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
示例#10
0
        /// <summary>
        /// This method returns list of funding sources that have not been deleted
        /// for display during Fund Account
        /// </summary>
        /// <param name="sourceIds">sourceIds</param>
        /// <param name="organizationID">organizationID</param>
        /// <returns></returns>
        public List <FundTransferSourceDetail> GetAllClientTransferFundSources(string sourceIds, int organizationID)
        {
            try
            {
                //Array of source ids
                var arrIds = sourceIds.Split(',');

                using (var unitOfWork = new EFUnitOfWork())
                {
                    var fundSourceRepo =
                        new FundingSourceRepository(new EFRepository <FundingSource>(), unitOfWork);

                    ObjectSet <FundingSource> fundSourceObjSet =
                        ((CurrentDeskClientsEntities)fundSourceRepo.Repository.UnitOfWork.Context).FundingSources;

                    //Get all active sources
                    var activeSources =
                        fundSourceObjSet.Include("L_Country").Where(src => src.FK_OrganizationID == organizationID && src.IsDeleted == false && src.IsEnabled == true).ToList();

                    //Filter and return
                    return(activeSources.Where(src => arrIds.Contains(src.PK_FundingSourceID.ToString())).Select(x => new FundTransferSourceDetail
                    {
                        PK_FundingSourceID = x.PK_FundingSourceID,
                        BankDetail = x.BankName + " - " + x.L_Country.CountryName
                    }).ToList());
                }
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
示例#11
0
        /// <summary>
        /// This method returns list of funding sources based on sourceids passed
        /// </summary>
        /// <param name="sourceIds">sourceIds</param>
        /// <param name="organizationID">organizationID</param>
        /// <returns></returns>
        public List <FundingSource> GetFundingSourcesFromIDs(string sourceIds, int organizationID)
        {
            try
            {
                using (var unitOfWork = new EFUnitOfWork())
                {
                    //Array of source ids
                    var arrIds = sourceIds.Split(',');

                    var fundSourceRepo =
                        new FundingSourceRepository(new EFRepository <FundingSource>(), unitOfWork);

                    ObjectSet <FundingSource> fundSourceObjSet =
                        ((CurrentDeskClientsEntities)fundSourceRepo.Repository.UnitOfWork.Context).FundingSources;

                    //Get all active sources
                    var activeSources =
                        fundSourceObjSet.Where(src => src.IsDeleted == false && src.IsEnabled == true && src.FK_OrganizationID == organizationID).ToList();

                    //Filter and return
                    return(activeSources.Where(src => arrIds.Contains(src.PK_FundingSourceID.ToString())).ToList());
                }
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
        /// <summary>
        /// This method returns currency account code for a particular currency
        /// </summary>
        /// <param name="pkCurrencyID">pkCurrencyID</param>
        /// <returns></returns>
        public string GetCurrencyAccountCode(int?pkCurrencyID)
        {
            try
            {
                return(GetCurrencies().Where(curr => curr.PK_CurrencyValueID == pkCurrencyID).
                       Select(curr => curr.AccountCurrencyCode).SingleOrDefault());
                //using (var unitOfWork = new EFUnitOfWork())
                //{
                //    var lCurrencyRepo =
                //        new L_CurrencyValueRepository(new EFRepository<L_CurrencyValue>(), unitOfWork);

                //    //Creating Currency Objeset to Query
                //    ObjectSet<L_CurrencyValue> currencyObjSet =
                //      ((CurrentDeskClientsEntities)lCurrencyRepo.Repository.UnitOfWork.Context).L_CurrencyValue;

                //    //Return the selected string
                //    return currencyObjSet.Where(curr => curr.PK_CurrencyValueID == pkCurrencyID).
                //        Select(curr => curr.AccountCurrencyCode).SingleOrDefault();

                //}
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
 /// <summary>
 /// This method returns currency image class as per curr id
 /// </summary>
 /// <param name="pkCurrencyID"></param>
 /// <returns></returns>
 public string GetCurrencyImageClass(int pkCurrencyID)
 {
     try
     {
         if (pkCurrencyID == 5)
         {
             return("usd");
         }
         if (pkCurrencyID == 4)
         {
             return("gbp");
         }
         if (pkCurrencyID == 3)
         {
             return("eur");
         }
         if (pkCurrencyID == 2)
         {
             return("chf");
         }
         if (pkCurrencyID == 1)
         {
             return("aud");
         }
         return("");
     }
     catch (Exception ex)
     {
         CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
         throw;
     }
 }
        /// <summary>
        /// This method inserts inter client transfer activity details in db
        /// </summary>
        /// <param name="pkUsrActivityId">pkUsrActivityId</param>
        /// <param name="fromUserId">fromUserId</param>
        /// <param name="toUserId">toUserId</param>
        /// <param name="currId">currId</param>
        /// <param name="amount">amount</param>
        /// <param name="fromAcc">fromAcc</param>
        /// <param name="toAcc">toAcc</param>
        /// <param name="status">status</param>
        public void InsertInterClientTransferActivityDetails(int pkUsrActivityId, int?fromUserId, int?toUserId, int currId, double amount, string fromAcc, string toAcc, string status)
        {
            try
            {
                using (var unitOfWork = new EFUnitOfWork())
                {
                    var transferActRepo =
                        new TransferActivityRepository(new EFRepository <TransferActivity>(), unitOfWork);

                    var newTransferAct = new TransferActivity();
                    newTransferAct.FK_UserActivityID = pkUsrActivityId;
                    newTransferAct.FK_CurrencyID     = currId;
                    newTransferAct.TransferAmount    = Convert.ToDecimal(amount);
                    newTransferAct.FromAccount       = fromAcc;
                    newTransferAct.ToAccount         = toAcc;
                    newTransferAct.FK_ToUserID       = toUserId;
                    newTransferAct.FK_FromUserID     = fromUserId;
                    newTransferAct.TransferStatus    = status;

                    transferActRepo.Add(newTransferAct);
                    transferActRepo.Save();
                }
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
        /// <summary>
        /// This Function Will Update The Joint-Account Personal Information of Introducing Broker
        /// </summary>
        /// <param name="userID">userID</param>
        /// <param name="phoneID">PhoneID</param>
        /// <returns>result</returns>
        public bool UpdateJointPersonalInformation(int userID, string phoneID)
        {
            try
            {
                using (var unitOfWork = new EFUnitOfWork())
                {
                    var introducingBrokerRepo =
                        new IntroducingBrokerRepository(new EFRepository <IntroducingBroker>(), unitOfWork);

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

                    var updateRow = introducingBrokerObjSet.Where(x => x.FK_UserID == userID).
                                    Include("JointAccountInformations").FirstOrDefault();

                    //Update particular column value
                    updateRow.JointAccountInformations.FirstOrDefault().PhoneID = phoneID;

                    //Save changes
                    introducingBrokerRepo.Save();
                }
                return(true);
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                return(false);
            }
        }
示例#16
0
        // Add your own data access methods here.  If you wish to
        // expose your public method to a WCF service, marked them with
        // the attribute [NCPublish], and another T4 template will generate your service contract

        /// <summary>
        /// This method gets list of user messages as per status
        /// </summary>
        /// <param name="userID">userID</param>
        /// <param name="status">status</param>
        /// <param name="sortColName">sortColName</param>
        /// <param name="sortOrder">sortOrder</param>
        /// <returns></returns>
        public List <InternalUserMessage> GetUserMessages(int userID, string status, string sortColName, string sortOrder)
        {
            try
            {
                using (var unitOfWork = new EFUnitOfWork())
                {
                    var userMsgRepo =
                        new InternalUserMessageRepository(new EFRepository <InternalUserMessage>(), unitOfWork);

                    ObjectSet <InternalUserMessage> userMsgObjSet =
                        ((CurrentDeskClientsEntities)userMsgRepo.Repository.UnitOfWork.Context).InternalUserMessages;

                    //Get sort param name by reflection
                    var sortParam = typeof(InternalUserMessage).GetProperty(sortColName);

                    //Sort order asc
                    if (String.Equals(sortOrder.ToLower(), "asc"))
                    {
                        var userMsgs = userMsgObjSet.Where(msg => msg.FK_ToUserID == userID && msg.MessageStatus == status && msg.IsDeleted == false).ToList();
                        return(userMsgs.OrderBy(msg => sortParam.GetValue(msg, null)).ToList());
                    }
                    //Sort order desc
                    else
                    {
                        var userMsgs = userMsgObjSet.Where(msg => msg.FK_ToUserID == userID && msg.MessageStatus == status && msg.IsDeleted == false).ToList();
                        return(userMsgs.OrderByDescending(msg => sortParam.GetValue(msg, null)).ToList());
                    }
                }
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
        /// <summary>
        /// This Function Will Update Joint Account Contact Information Of Introducing Broker
        /// </summary>
        /// <param name="userID">userID</param>
        /// <param name="jointAccountInformation">jointAccountInformation</param>
        /// <returns>result</returns>
        public bool UpdateJointContactInforamation(int userID, JointAccountInformation jointAccountInformation)
        {
            try
            {
                using (var unitOfWork = new EFUnitOfWork())
                {
                    var introducingBrokerRepo =
                        new IntroducingBrokerRepository(new EFRepository <IntroducingBroker>(), unitOfWork);

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

                    var updateRow = introducingBrokerObjSet.Where(x => x.FK_UserID == userID).
                                    Include("JointAccountInformations").Include("User").FirstOrDefault();

                    //Update particular column values
                    updateRow.JointAccountInformations.FirstOrDefault().TelephoneNumber = jointAccountInformation.TelephoneNumber;
                    updateRow.JointAccountInformations.FirstOrDefault().MobileNumber    = jointAccountInformation.MobileNumber;
                    updateRow.User.UserEmailID = jointAccountInformation.EmailAddress;
                    //if (updateRow.AssetManagers.FirstOrDefault() != null)
                    //{
                    //    updateRow.AssetManagers.FirstOrDefault().UserEmail = jointAccountInformation.EmailAddress;
                    //}

                    //Save changes
                    introducingBrokerRepo.Save();
                }
                return(true);
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                return(true);
            }
        }
        /// <summary>
        /// Calculate Equity for clients
        /// </summary>
        /// <param name="loginid"></param>
        /// <returns></returns>
        public decimal GetValueForEquity(int loginid)
        {
            decimal equityForClients = 0;

            try
            {
                dynamic openTrade = (dynamic)tradeBO.GetUserOpenTrades(loginid);

                //Get Margin Balance
                decimal balance = marginBO.GetMarginBalance(loginid);

                //Get Credit amout
                decimal credit = Convert.ToDecimal(userRecordBO.CreditAmount(loginid));

                //Actual balance
                decimal actualbalance = balance - credit;


                var pnl       = openTrade.GetType().GetProperty("Pnl").GetValue(openTrade, null);
                var commision = openTrade.GetType().GetProperty("Commision").GetValue(openTrade, null);
                var swap      = openTrade.GetType().GetProperty("Swap").GetValue(openTrade, null);

                equityForClients = actualbalance + Convert.ToDecimal(pnl) + Convert.ToDecimal(commision) + Convert.ToDecimal(swap);
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
            }

            return(equityForClients);
        }
        /// <summary>
        /// This method saves referral link in IB table
        /// </summary>
        /// <param name="userID">userID</param>
        /// <param name="referralLink">referralLink</param>
        /// <returns></returns>
        public bool SaveReferralLink(int userID, string referralLink)
        {
            try
            {
                using (var unitOfWork = new EFUnitOfWork())
                {
                    var ibRepo =
                        new IntroducingBrokerRepository(new EFRepository <IntroducingBroker>(), unitOfWork);

                    ObjectSet <IntroducingBroker> ibObjSet =
                        ((CurrentDeskClientsEntities)ibRepo.Repository.UnitOfWork.Context).IntroducingBrokers;

                    var ibRow = ibObjSet.Include("User").Where(usr => usr.User.PK_UserID == userID).FirstOrDefault();
                    if (ibRow != null)
                    {
                        ibRow.CustomizedLink = referralLink;
                        ibRepo.Save();
                        return(true);
                    }
                    return(false);
                }
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
示例#20
0
        /// <summary>
        /// This Function will get all the Trades dependng
        /// upon the platform login
        /// </summary>
        /// <param name="platformLoginList">platformLoginList</param>
        /// <param name="fromDate">fromDate</param>
        /// <param name="toDate">toDate</param>
        /// <returns>TradesHistory List</returns>
        public List <TradesHistory> GetAllCurrencyCFDTradesByPlatformLogin(List <int?> platformLoginList, long fromDate, long toDate)
        {
            try
            {
                List <int> cfdCodeList = new List <int>()
                {
                    1, 3, 4
                };
                using (var unitOfWork = new EFUnitOfWork())
                {
                    var tradeHistoryRepo =
                        new TradesHistoryRepository(new EFRepository <TradesHistory>(), unitOfWork);

                    var tradeHistoryList = ((CurrentDeskClientsEntities)tradeHistoryRepo.Repository.UnitOfWork.Context).TradesHistories.
                                           Where(x => platformLoginList.Contains(x.Login) &&
                                                 x.Timestamp > fromDate &&
                                                 x.Timestamp < toDate && x.MarginMode != null).ToList();

                    tradeHistoryList = tradeHistoryList.Where(x => cfdCodeList.Contains((int)x.MarginMode)).ToList();

                    return(tradeHistoryList);
                }
            }
            catch (Exception exceptionMessage)
            {
                CommonErrorLogger.CommonErrorLog(exceptionMessage, System.Reflection.MethodBase.GetCurrentMethod().Name);
                return(null);
            }
        }
        public string GetSelectedCompany(int selectedCompanyID)
        {
            try
            {
                return(GetCompanyType().Where(cmp => cmp.PK_CompanyTypeID == selectedCompanyID).Select(cmp => cmp.CompanyType).SingleOrDefault());

                //using (var unitOfWork = new EFUnitOfWork())
                //{
                //    var lCompanyTypeRepo =
                //        new L_CompanyTypeValueRepository(new EFRepository<L_CompanyTypeValue>(), unitOfWork);

                //    //Creating Country Objeset to Query
                //    ObjectSet<L_CompanyTypeValue> companyTypeObjSet =
                //      ((CurrentDeskClientsEntities)lCompanyTypeRepo.Repository.UnitOfWork.Context).L_CompanyTypeValue;

                //    //Return the selected string
                //    return companyTypeObjSet.Where(cmp => cmp.PK_CompanyTypeID == selectedCompanyID).
                //        Select(cmp => cmp.CompanyType).SingleOrDefault();

                //}
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
示例#22
0
        /// <summary>
        /// This method logs fee transaction details in Transactions table
        /// </summary>
        /// <param name="fromAcc">fromAcc</param>
        /// <param name="fromCurrID">fromCurrID</param>
        /// <param name="toCurrID">toCurrID</param>
        /// <param name="fee">fee</param>
        /// <param name="organizationID">organizationID</param>
        /// <returns>int</returns>
        public int InternalFeeTransaction(string fromAcc, int fromCurrID, int toCurrID, double fee, int organizationID)
        {
            try
            {
                using (var unitOfWork = new EFUnitOfWork())
                {
                    var transactionRepo =
                        new TransactionRepository(new EFRepository <Transaction>(), unitOfWork);

                    ObjectSet <Transaction> transactionObjSet =
                        ((CurrentDeskClientsEntities)transactionRepo.Repository.UnitOfWork.Context).Transactions;

                    Transaction newTransaction = new Transaction();
                    newTransaction.FK_FromCurrencyID   = fromCurrID;
                    newTransaction.FK_ToCurrencyID     = toCurrID;
                    newTransaction.Amount              = Convert.ToDecimal(fee);
                    newTransaction.FromAccount         = fromAcc;
                    newTransaction.TransactionType     = "Fee";
                    newTransaction.TransactionDateTime = DateTime.UtcNow;
                    newTransaction.FK_OrganizationID   = organizationID;

                    transactionRepo.Add(newTransaction);
                    transactionRepo.Save();

                    return(newTransaction.PK_TransactionID);
                }
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
示例#23
0
        /// <summary>
        /// This method disables an agent of IB
        /// </summary>
        /// <param name="agentID">agentID</param>
        /// <param name="introducingBrokerUserID">introducingBrokerUserID</param>
        /// <returns></returns>
        public bool DisableAgent(int agentID, int introducingBrokerUserID)
        {
            try
            {
                using (var unitOfWork = new EFUnitOfWork())
                {
                    var agentRepo =
                        new AgentRepository(new EFRepository <Agent>(), unitOfWork);

                    ObjectSet <Agent> agentObjSet =
                        ((CurrentDeskClientsEntities)agentRepo.Repository.UnitOfWork.Context).Agents;

                    //Get the agent
                    var agent = agentObjSet.Where(agnt => agnt.FK_IntroducingBrokerUserID == introducingBrokerUserID && agnt.AgentIntroducingBrokerCode == agentID).FirstOrDefault();

                    //Change active status
                    if (agent != null)
                    {
                        agent.IsActive = false;

                        agentRepo.Save();
                        return(true);
                    }
                    return(false);
                }
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                return(false);
            }
        }
示例#24
0
        /// <summary>
        /// This method inserts withdraw record transaction in table
        /// </summary>
        /// <param name="accountNumber">accountNumber</param>
        /// <param name="currID">currID</param>
        /// <param name="amount">amount</param>
        /// <param name="notes">notes</param>
        /// <param name="organizationID">organizationID</param>
        /// <returns></returns>
        public int FundWithdraw(string accountNumber, int currID, decimal amount, string notes, int organizationID)
        {
            try
            {
                using (var unitOfWork = new EFUnitOfWork())
                {
                    var transactionRepo =
                        new TransactionRepository(new EFRepository <Transaction>(), unitOfWork);

                    Transaction newTransaction = new Transaction();
                    newTransaction.FK_FromCurrencyID   = currID;
                    newTransaction.FK_ToCurrencyID     = currID;
                    newTransaction.Amount              = Convert.ToDecimal(amount);
                    newTransaction.FromAccount         = accountNumber;
                    newTransaction.ToAccount           = accountNumber;
                    newTransaction.ExchangeRate        = "1";
                    newTransaction.Notes               = notes;
                    newTransaction.TransactionType     = "Withdraw";
                    newTransaction.TransactionDateTime = DateTime.UtcNow;
                    newTransaction.FK_OrganizationID   = organizationID;

                    transactionRepo.Add(newTransaction);
                    transactionRepo.Save();

                    return(newTransaction.PK_TransactionID);
                }
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
示例#25
0
        /// <summary>
        /// This method deletes user document by setting IsDeleted column to true
        /// </summary>
        /// <param name="userID">userID</param>
        /// <param name="docID">docID</param>
        /// <returns></returns>
        public string ClearUserDocument(int userID, int docID)
        {
            try
            {
                using (var unitOfWork = new EFUnitOfWork())
                {
                    var userDocRepo =
                        new UserDocumentRepository(new EFRepository <UserDocument>(), unitOfWork);

                    ObjectSet <UserDocument> userDocObjSet =
                        ((CurrentDeskClientsEntities)userDocRepo.Repository.UnitOfWork.Context).UserDocuments;

                    var userDoc = userDocObjSet.Where(doc => doc.FK_UserID == userID && doc.FK_DocumentID == docID && doc.IsDeleted == false).FirstOrDefault();

                    if (userDoc != null)
                    {
                        userDoc.IsDeleted = true;
                        userDocRepo.Save();
                        return(userDoc.UserDocumentName);
                    }

                    return(String.Empty);
                }
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
示例#26
0
        // Add your own data access methods here.  If you wish to
        // expose your public method to a WCF service, marked them with
        // the attribute [NCPublish], and another T4 template will generate your service contract

        /// <summary>
        /// This method logs transaction details in Transactions table
        /// </summary>
        /// <param name="fromAcc">fromAcc</param>
        /// <param name="toAcc">toAcc</param>
        /// <param name="fromCurrID">fromCurrID</param>
        /// <param name="toCurrID">toCurrID</param>
        /// <param name="amount">amount</param>
        /// <param name="exchangeRate">exchangeRate</param>
        /// <param name="notes">notes</param>
        /// <returns>int</returns>
        public int InternalFundTransfer(string fromAcc, string toAcc, int fromCurrID, int toCurrID, double amount, double exchangeRate, string notes)
        {
            try
            {
                using (var unitOfWork = new EFUnitOfWork())
                {
                    var transactionRepo =
                        new TransactionRepository(new EFRepository <Transaction>(), unitOfWork);

                    ObjectSet <Transaction> transactionObjSet =
                        ((CurrentDeskClientsEntities)transactionRepo.Repository.UnitOfWork.Context).Transactions;

                    Transaction newTransaction = new Transaction();
                    newTransaction.FK_FromCurrencyID   = fromCurrID;
                    newTransaction.FK_ToCurrencyID     = toCurrID;
                    newTransaction.Amount              = Convert.ToDecimal(amount);
                    newTransaction.FromAccount         = fromAcc;
                    newTransaction.ToAccount           = toAcc;
                    newTransaction.ExchangeRate        = exchangeRate.ToString();
                    newTransaction.Notes               = notes;
                    newTransaction.TransactionType     = "Internal";
                    newTransaction.TransactionDateTime = DateTime.UtcNow;

                    transactionRepo.Add(newTransaction);
                    transactionRepo.Save();

                    return(newTransaction.PK_TransactionID);
                }
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
        /// <summary>
        /// This Function Will return all the net worth euros values
        /// </summary>
        /// <returns></returns>
        public List <L_TradingExperience> GetTradingExpValues()
        {
            try
            {
                var tradingExpKey  = CacheKey.CDS_TRADINGEXPS;
                var tradingExpList = new List <L_TradingExperience>();

                if (StaticCache.Exist(tradingExpKey))
                {
                    tradingExpList = (List <L_TradingExperience>)StaticCache.Get(tradingExpKey);
                }
                else
                {
                    using (var unitOfWork = new EFUnitOfWork())
                    {
                        var lTradingExpRepo =
                            new L_TradingExperienceRepository(new EFRepository <L_TradingExperience>(), unitOfWork);

                        //Returning list of trading exp look up values
                        tradingExpList = lTradingExpRepo.All().ToList();

                        StaticCache.Max(tradingExpKey, tradingExpList);
                    }
                }

                return(tradingExpList);
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
        /// <summary>
        /// This Function Will get all the Platform logins of all the clients
        /// of respective introducing broker.
        /// </summary>
        /// <returns></returns>
        public List <int?> GetPlatformLoginsIntroducingBroker(int userID)
        {
            try
            {
                using (var unitOfWork = new EFUnitOfWork())
                {
                    var introducingBrokerRepo =
                        new IntroducingBrokerRepository(new EFRepository <IntroducingBroker>(), unitOfWork);

                    //Get IntroducingBrokedID
                    var introducingBrokerID = GetBrokerIDFromBrokerUserID(userID);

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

                    //var introducingBrokerList = introducingBrokerObjSet.Include("Client_Account").
                    //                            Where(x => x.PK_IntroducingBrokerID == introducingBrokerID).ToList();

                    var context           = ((CurrentDeskClientsEntities)introducingBrokerRepo.Repository.UnitOfWork.Context);
                    var platformLoginList = (from ib in context.IntroducingBrokers
                                             join cl in context.Clients on ib.PK_IntroducingBrokerID equals cl.FK_IntroducingBrokerID
                                             join ca in context.Client_Account on cl.PK_ClientID equals ca.FK_ClientID
                                             where (ib.PK_IntroducingBrokerID == introducingBrokerID && ca.PlatformLogin != null)
                                             select ca.PlatformLogin).ToList();

                    return(platformLoginList);
                }
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
        /// <summary>
        /// This Function Will return all the AccountCODE
        /// </summary>
        /// <returns></returns>
        public List <L_AccountCode> GetAccountCodes()
        {
            try
            {
                var accountCodeKey  = CacheKey.CDS_ACCOUNTCODE;
                var accountCodeList = new List <L_AccountCode>();

                if (StaticCache.Exist(accountCodeKey))
                {
                    accountCodeList = (List <L_AccountCode>)StaticCache.Get(accountCodeKey);
                }
                else
                {
                    using (var unitOfWork = new EFUnitOfWork())
                    {
                        var lAccountRepo =
                            new L_AccountCodeRepository(new EFRepository <L_AccountCode>(), unitOfWork);

                        //Returning List Of Demo Lead
                        accountCodeList = lAccountRepo.All().ToList();

                        //Store it into the cache
                        StaticCache.Max(accountCodeKey, accountCodeList);
                    }
                }

                return(accountCodeList);
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
        /// <summary>
        /// This Function Will return all the net worth euros values
        /// </summary>
        /// <returns></returns>
        public List <L_NetWorthEuros> GetNetWorthEurosValues()
        {
            try
            {
                var netWorthKey  = CacheKey.CDS_NETWORTHEUROS;
                var netWorthList = new List <L_NetWorthEuros>();

                if (StaticCache.Exist(netWorthKey))
                {
                    netWorthList = (List <L_NetWorthEuros>)StaticCache.Get(netWorthKey);
                }
                else
                {
                    using (var unitOfWork = new EFUnitOfWork())
                    {
                        var lNetWorthEurosRepo =
                            new L_NetWorthEurosRepository(new EFRepository <L_NetWorthEuros>(), unitOfWork);

                        //Returning list of net worth euros look up values
                        netWorthList = lNetWorthEurosRepo.All().ToList();

                        StaticCache.Max(netWorthKey, netWorthList);
                    }
                }

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