/// <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; } }
/// <summary> /// This method returns bank account details based on pkBankID /// </summary> /// <param name="pkBankInfoID">pkBankInfoID</param> /// <returns></returns> public BankAccountInformation GetBankAccountDetails(int pkBankInfoID) { try { using (var unitOfWork = new EFUnitOfWork()) { var bankRepo = new BankAccountInformationRepository(new EFRepository <BankAccountInformation>(), unitOfWork); ObjectSet <BankAccountInformation> bankAccountInformationObjSet = ((CurrentDeskClientsEntities)bankRepo.Repository.UnitOfWork.Context).BankAccountInformations; return(bankAccountInformationObjSet.Where(bnk => bnk.PK_BankAccountInformationID == pkBankInfoID).FirstOrDefault()); } } catch (Exception ex) { CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); throw; } }
/// <summary> /// This method updates bank account information of particular bank /// </summary> /// <param name="bankAccountInformation">bankAccountInformation</param> /// <returns></returns> public bool UpdateBankAccountInformation(BankAccountInformation bankAccountInformation) { try { using (var unitOfWork = new EFUnitOfWork()) { var bankAccountRepo = new BankAccountInformationRepository(new EFRepository <BankAccountInformation>(), unitOfWork); ObjectSet <BankAccountInformation> bankAccountInformationObjSet = ((CurrentDeskClientsEntities)bankAccountRepo.Repository.UnitOfWork.Context).BankAccountInformations; var selectedBankInformation = bankAccountInformationObjSet. Where(binfo => binfo.PK_BankAccountInformationID == bankAccountInformation.PK_BankAccountInformationID).SingleOrDefault(); if (selectedBankInformation != null) { selectedBankInformation.BankName = bankAccountInformation.BankName; selectedBankInformation.AccountNumber = bankAccountInformation.AccountNumber; selectedBankInformation.BicNumberOrSwiftCode = bankAccountInformation.BicNumberOrSwiftCode; selectedBankInformation.BankingAddress = bankAccountInformation.BankingAddress; selectedBankInformation.FK_ReceivingBankInformationID = bankAccountInformation.FK_ReceivingBankInformationID; selectedBankInformation.ReceivingBankInfo = bankAccountInformation.ReceivingBankInfo; selectedBankInformation.City = bankAccountInformation.City; selectedBankInformation.FK_CountryID = bankAccountInformation.FK_CountryID; selectedBankInformation.PostalCode = bankAccountInformation.PostalCode; } bankAccountRepo.Save(); return(true); } } catch (Exception ex) { CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); throw; } }
/// <summary> /// This method adds new bank account for Live user /// </summary> /// <param name="userID">userID</param> /// <param name="bankAccountInformation">bankAccountInformation</param> /// <returns></returns> public bool AddNewLiveBankAccountInformation(int userID, BankAccountInformation bankAccountInformation) { try { using (var unitOfWork = new EFUnitOfWork()) { var bankRepo = new BankAccountInformationRepository(new EFRepository <BankAccountInformation>(), unitOfWork); var clientBO = new ClientBO(); var clientInformation = clientBO.GetClientInformation(userID); bankAccountInformation.FK_ClientID = clientInformation.PK_ClientID; bankRepo.Add(bankAccountInformation); bankRepo.Save(); return(true); } } catch (Exception ex) { CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); throw; } }