/// <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>
        /// This method validates user during login
        /// </summary>
        /// <param name="userName">userName</param>
        /// <param name="password">password</param>
        /// <param name="userID">userID</param>
        /// <param name="userType">userType</param>
        /// <param name="accountType">accountType</param>
        /// <param name="accountCode">accountCode</param>
        /// <param name="userDisplayName">userDisplayName</param>
        /// <returns></returns>
        public bool ValidateUser(string userName, string password, int organizationID, ref int userID, ref int userType,
                                 ref int accountType, ref int accountCode, ref string userDisplayName)
        {
            var currentDeskSecurity = new CurrentDeskSecurity();

            try
            {
                using (var unitOfWork = new EFUnitOfWork())
                {
                    var userRepo =
                        new UserRepository(new EFRepository <User>(), unitOfWork);

                    ObjectSet <User> userObjSet =
                        ((CurrentDeskClientsEntities)userRepo.Repository.UnitOfWork.Context).Users;

                    //Get The Selected client and check for the
                    //organization and than assign its Properties.
                    var selectedUsers =
                        userObjSet.Where(usr => usr.UserEmailID == userName && usr.FK_OrganizationID == organizationID).FirstOrDefault();

                    if (selectedUsers != null)
                    {
                        if (currentDeskSecurity.GetPassDecrypted(selectedUsers.Password) == password)
                        {
                            userID   = selectedUsers.PK_UserID;
                            userType = (int)selectedUsers.FK_UserTypeID;

                            if (selectedUsers.FK_UserTypeID == Constants.K_BROKER_LIVE)
                            {
                                var clientBO = new ClientBO();
                                return(clientBO.GetClientAccountInformation(selectedUsers.PK_UserID, ref accountType, ref accountCode, ref userDisplayName));
                            }
                            else if (selectedUsers.FK_UserTypeID == Constants.K_BROKER_PARTNER)
                            {
                                var introducingBrokerBO = new IntroducingBrokerBO();
                                return(introducingBrokerBO.GetClientAccountInformation(selectedUsers.PK_UserID, ref accountType, ref accountCode, ref userDisplayName));
                            }
                            else if (selectedUsers.FK_UserTypeID == Constants.K_BROKER_ADMIN)
                            {
                                accountCode = Constants.K_ACCTCODE_SUPERADMIN;
                                return(true);
                            }
                        }
                    }

                    return(false);
                }
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
예제 #3
0
        /// <summary>
        /// This method returns all clients of broker with name and account number
        /// </summary>
        /// <param name="organizationID">organizationID</param>
        /// <param name="accountNumberPosition">accountNumberPosition</param>
        /// <returns></returns>
        public List <BrokerClients> GetAllClientsOfBroker(int organizationID, int accountNumberPosition)
        {
            try
            {
                using (var unitOfWork = new EFUnitOfWork())
                {
                    List <BrokerClients> lstAllClients       = new List <BrokerClients>();
                    ClientBO             clientBO            = new ClientBO();
                    IntroducingBrokerBO  introducingBrokerBO = new IntroducingBrokerBO();

                    var userRepo =
                        new UserRepository(new EFRepository <User>(), unitOfWork);

                    ObjectSet <User> userObjSet =
                        ((CurrentDeskClientsEntities)userRepo.Repository.UnitOfWork.Context).Users;

                    //Get all live and partner clients
                    var allClients = userObjSet.Where(usr => usr.FK_OrganizationID == organizationID && (usr.FK_UserTypeID == Constants.K_BROKER_LIVE || usr.FK_UserTypeID == Constants.K_BROKER_PARTNER)).ToList();

                    //Get live and partner clients names with a/c numbers
                    var liveClients    = clientBO.GetClientNames(allClients, accountNumberPosition);
                    var partnerClients = introducingBrokerBO.GetPartnerNames(allClients, accountNumberPosition);

                    //Merger both and add to list
                    lstAllClients.AddRange(liveClients);
                    lstAllClients.AddRange(partnerClients);

                    //Return list of clients
                    return(lstAllClients);
                }
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
        /// <summary>
        /// This method adds new bank account information for Partner user
        /// </summary>
        /// <param name="userID">userID</param>
        /// <param name="bankAccountInformation">bankAccountInformation</param>
        /// <returns></returns>
        public bool AddNewPartnerBankAccountInformation(int userID, BankAccountInformation bankAccountInformation)
        {
            try
            {
                using (var unitOfWork = new EFUnitOfWork())
                {
                    var bankRepo            = new BankAccountInformationRepository(new EFRepository <BankAccountInformation>(), unitOfWork);
                    var introducingBrokerBO = new IntroducingBrokerBO();

                    var clientInformation = introducingBrokerBO.GetClientInformation(userID);
                    bankAccountInformation.FK_IntroducingBrokerID = clientInformation.PK_IntroducingBrokerID;

                    bankRepo.Add(bankAccountInformation);
                    bankRepo.Save();

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