public SelfReportedLoanListModel SaveSelfReportedLoansWithFileName(string sourceName, Stream file) { var reader = new StreamReader(file); var fileBytes = Encoding.ASCII.GetBytes(reader.ReadToEnd()); var userId = _memberAdapter.GetMemberIdFromContext(); List <MemberReportedLoanContract> loanList; SelfReportedLoanListModel errorObj = new SelfReportedLoanListModel(); try { loanList = SaltServiceAgent.ImportLoanFile(userId, fileBytes, sourceName); if (loanList.Count == 0) { //return an error message so user knows that loans were not imported errorObj.ErrorList.Add(new ErrorModel("No loans returned")); return(errorObj); } else { return(loanList.FromMemberReportedLoanContractList()); } } catch (Exception ex) { //return error with message from SALT Service errorObj.Loans = new List <SelfReportedLoanModel>(); errorObj.ErrorList.Add(new ErrorModel(ex.Message)); return(errorObj); } }
public void LogSRLData(string p, SelfReportedLoanListModel srList) { if (_log.IsDebugEnabled) { try { StringBuilder sb = new StringBuilder("\n" + p + "\n"); if (srList != null && srList.Loans != null) { foreach (SelfReportedLoanModel loan in srList.Loans) { sb.AppendLine("loan.IndividualId = " + (!string.IsNullOrEmpty(loan.IndividualId) ? loan.IndividualId : "NULL or EMPTY")); sb.AppendLine("loan.LoanSelfReportedEntryId = " + (!string.IsNullOrEmpty(loan.LoanSelfReportedEntryId) ? loan.LoanSelfReportedEntryId : "NULL or EMPTY")); sb.AppendLine("loan.IsActive = " + loan.IsActive); sb.AppendLine("loan.LoanStatusId = " + (!string.IsNullOrEmpty(loan.LoanStatusId) ? loan.LoanStatusId : "NULL or EMPTY")); sb.AppendLine("loan.NewRecord = " + loan.NewRecord); sb.AppendLine("loan.OriginalLoanAmount = " + loan.OriginalLoanAmount.ToString()); sb.AppendLine("loan.PrincipalBalanceOutstandingAmount = " + loan.PrincipalBalanceOutstandingAmount.ToString()); sb.AppendLine("loan.LoanTerm = " + loan.LoanTerm.ToString()); } } _log.Debug(sb.ToString()); } catch { _log.Debug("Problem logging SelfReportedLoan data. msg = " + p); } } }
public void Validation_ValidSelfReportedLoanNullLists() { SelfReportedLoanListModel srlList = new SelfReportedLoanListModel(); srlList.Loans = null; bool bValid = srlList.IsValid(); Assert.IsTrue(bValid, "This SelfReportedLoanList failed validation when it has a null Loan list."); }
/// <summary> /// Converts the member reported loan contract list to the domain model. /// </summary> /// <param name="loans">The loans.</param> /// <returns></returns> public static SelfReportedLoanListModel FromMemberReportedLoanContractList(this List <MemberReportedLoanContract> loans) { var list = new SelfReportedLoanListModel(); foreach (var loan in loans) { list.Loans.Add(loan.FromMemberReportedLoanContract()); } return(list); }
public void Validation_ValidSelfReportedLoanListModel() { SelfReportedLoanModel srl = GetValidSelfReportedLoanData(); SelfReportedLoanListModel srlList = new SelfReportedLoanListModel(); srlList.Loans.Add(srl); bool bValid = srlList.IsValid(); Assert.IsTrue(bValid, "A SelfReportedLoanListModel with all good information validated incorrectly."); }
private SelfReportedLoanListModel RemoveInvalidLoansFromList(SelfReportedLoanListModel srList) { //get Id of the member currently logged-in SiteMember sm = IntegrationLoader.LoadDependency <ISiteMembership>("siteMembership").GetMember(); string individualId = ""; if (sm != null && sm.Profile != null && sm.Profile.Id != null) { individualId = sm.Profile.Id.ToString(); _log.Debug(string.Format("SiteMember.Profile.Id = {0}", individualId)); } List <string> invalidLoanIdList = new List <string>(); //get list of current SRL's for the member logged-in if (!string.IsNullOrEmpty(individualId)) { SelfReportedLoanListModel srListFromDB = GetSelfReportedLoans(individualId); foreach (SelfReportedLoanModel srl in srList.Loans) { if (!string.IsNullOrEmpty(srl.LoanSelfReportedEntryId) && srListFromDB != null)//only care about loans being updated here. { bool foundValidLoan = false; foreach (SelfReportedLoanModel srlFromDB in srListFromDB.Loans) { if (srl.LoanSelfReportedEntryId == srlFromDB.LoanSelfReportedEntryId) { foundValidLoan = true; break; } } // if a loan attempting to be updated by user isn't in DB, then user is tampering. Remove that loan from the update list. if (!foundValidLoan) { invalidLoanIdList.Add(srl.LoanSelfReportedEntryId); _log.Warn(string.Format("User attempted to save loan information that did not belong to them. User = {0}, LoanSelfReportedEntryId = {1}", individualId, srl.LoanSelfReportedEntryId)); } } } foreach (string str in invalidLoanIdList) { SelfReportedLoanModel srl = srList.Loans.Find(l => l.LoanSelfReportedEntryId == str); if (srl != null) { srList.Loans.Remove(srl); } } } return(srList); }
/// <summary> /// /// </summary> /// <param name="loans"></param> /// <param name="memberID"></param> /// <returns></returns> public static MemberReportedLoanContract[] ToMemberReportedLoanContractList(this SelfReportedLoanListModel loans, int memberID) { MemberReportedLoanContract[] list = new MemberReportedLoanContract[loans.Loans.Count]; int i = 0; foreach (var loan in loans.Loans) { list[i++] = loan.ToMemberReportedLoanContract(memberID); } return(list); }
public static XmlNode MapSelfReportedLoanListToXmlNode(SelfReportedLoanListModel srLoans) { XElement elem = new XElement("ASASelfReportedLoanObjects"); foreach (SelfReportedLoanModel srl in srLoans.Loans) { XElement srlElem = MapSelfReportedLoanToXElement(srl); elem.Add(srlElem); } return(xWebModelHelper.GetXmlNode(elem)); }
public void SelfReportedService_GetSelfReportedLoans_UserId() { var mockSaltServiceAgent = (SaltServiceAgentStub)IntegrationLoader.LoadDependency <ISaltServiceAgent>("saltServiceAgent"); mockSaltServiceAgent.GetUserReportedLoansResponses = new List <MemberReportedLoanContract>() { new MemberReportedLoanContract() { CreatedDate = DateTime.Now, MemberId = 1, MemberReportedLoanId = 2, RecordSourceId = 1, LoanName = "Loan Test 1", LoanType = "Self-Reported", InterestRate = 5, OriginalLoanAmount = 5000, PrincipalOutstandingAmount = 4000, ReceivedYear = 2011, LoanTerm = 8, ServicingOrganizationName = "Sallie Mae", RecordSource = new RecordSourceContract(), OriginalLoanDate = DateTime.Now, MonthlyPaymentAmount = 50, ModifiedDate = DateTime.Now }, new MemberReportedLoanContract() { CreatedDate = DateTime.Now, MemberId = 1, MemberReportedLoanId = 3, RecordSourceId = 1, LoanName = "Loan Test 2", LoanType = "Self-Reported", InterestRate = 5, OriginalLoanAmount = 2000, PrincipalOutstandingAmount = 1500, ReceivedYear = 2012, LoanTerm = 5, ServicingOrganizationName = "Sallie Mae", RecordSource = new RecordSourceContract(), OriginalLoanDate = DateTime.Now, MonthlyPaymentAmount = 50, ModifiedDate = DateTime.Now } }; SelfReported srl = new SelfReported(); SelfReportedLoanListModel loanList = srl.GetSelfReportedLoans(); Assert.AreEqual(2, loanList.Loans.Count); }
public SelfReportedLoanListModel GetLoans(string ssn) { _log.Debug(string.Format("START ASA.Web.Services.LoanService.GetLoan(): ssn={0}", !string.IsNullOrEmpty(ssn)?ssn:"null")); HttpHeadersHelper.SetNoCacheResponseHeaders(WebOperationContext.Current); SelfReportedLoanListModel loans = null; IAsaMemberAdapter memberAdapter = null; memberAdapter = new AsaMemberAdapter(); if (LoanValidation.ValidateInputSsn(ssn)) { _log.Debug("calling GetActiveDirectoryKeyFromContext now."); int? id = memberAdapter.GetMemberIdFromContext(); ASAMemberModel member = memberAdapter.GetMember(id.Value); if (_loanAdapter == null) { _log.Error(_loanAdapterExceptionMessage); loans = new SelfReportedLoanListModel(); ErrorModel error = new ErrorModel(_loanAdapterExceptionMessage, "Web Loan Service"); _log.Error("ASA.Web.Services.LoanService.GetLoan(): " + _loanAdapterExceptionMessage); loans.ErrorList.Add(error); } else if (member != null)// we should never try to retrieve loans for someone who isn't found as the logged-in member from context. { loans = _loanAdapter.GetLoans(ssn, member); } if (loans == null) { _log.Debug("No loans were retrieved for this SSN: " + ssn); loans = new SelfReportedLoanListModel(); loans.ErrorList.Add(new ErrorModel("No Loans were retrieved for this SSN.")); } } else { loans = new SelfReportedLoanListModel(); ErrorModel error = new ErrorModel("Invalid search criteria", "Web Loan Service"); _log.Warn("ASA.Web.Services.LoanService.GetLoan(): Invalid search criteria"); loans.ErrorList.Add(error); } _log.Debug(string.Format("END ASA.Web.Services.LoanService.GetLoan(): ssn={0}", !string.IsNullOrEmpty(ssn) ? ssn : "null")); return(loans); }
public SelfReportedLoanListModel GetLoans(string ssn, ASAMemberModel member) { _log.Debug("START GetLoans"); SelfReportedLoanListModel srlList = null; if (member != null) //TODO: Mehdi && member.Source != SourceType.SELF_REGISTERED_NO_MATCH) { ////the following hardcoded values are only for when you're being lazy and dont want to find a person to test GetPerson, MatchingPersonFound, and GetLoan //member.FirstName = "Dwayne"; //member.LastName = "Baker"; //member.DOB = new DateTime(1976,1,30); //member.IndividualId = "967A954B-AB09-4713-9B6E-2067B8C3F992"; //ssn = "803450294"; // See if person is in ODS for this SSN GetPersonRequest getPersonRequest = TranslateLoanModel.MapSSNToGetPersonRequest(ssn); GetPersonResponse getPersonResponse = _proxyPerson.GetPerson(getPersonRequest); // if person was retrieved, do they match the FName, LName, and DOB from context? bool personMatchFound = MatchingPersonFound(member, getPersonResponse); if (personMatchFound) { _log.Debug("personMatchFound."); // save this person's SSN from ODS to Avectra bool ssnSaved = SaveSSNToAvectra(member, ssn); if (ssnSaved) { // go get this person's Loans from ODS GetLoanRequest getRequest = TranslateLoanModel.MapSsnToGetRequest(ssn, Config.LoanServiceMaxEntities); GetLoanResponse response = _proxyLoan.GetLoan(getRequest); srlList = TranslateLoanModel.MapGetResponseToModel(response, member.IndividualId); } } else { _log.Debug("NOT personMatchFound."); } } _log.Debug("END GetLoans"); return(srlList); }
public ResultCodeModel InsertSelfReportedLoans(SelfReportedLoanListModel srLoans) { ResultCodeModel result = new Common.ResultCodeModel(); if (srLoans == null) { _log.Info("Null SelfReportedLoan list object in ASA.Web.Services.SelfReportedService.SelfReportedAdapter.InsertSelfReportedLoans."); } else { // INSERT //xWebWrapper xWeb = new xWebWrapper(); //XmlNode node = TranslateSelfReportedModel.MapSelfReportedLoanListToXmlNode(srLoans); ////node = xWeb.InsertFacadeObject("ASASelfReportedLoan", node); //result = TranslateSelfReportedModel.MapXmlNodeToResultCodeModel(node); } return(result); }
public ResultCodeModel UpdateSelfReportedLoans(SelfReportedLoanListModel srLoans) { ResultCodeModel resultModel = new ResultCodeModel(); bool bHadSuccess = false; bool bHadPartialSuccess = false; bool bHadFail = false; if (srLoans != null && srLoans.Loans.Count > 0) { foreach (SelfReportedLoanModel srl in srLoans.Loans) { resultModel = UpdateSelfReportedLoan(srl); if (resultModel.ResultCode == 1) { bHadSuccess = true; } else if (resultModel.ResultCode == 2) { bHadPartialSuccess = true; } else { bHadFail = true; } } if (bHadPartialSuccess || (bHadFail && bHadSuccess)) { resultModel.ResultCode = 2; } else if (bHadFail) { resultModel.ResultCode = 0; } else { resultModel.ResultCode = 1; } } return(resultModel); }
private bool IsSRLForPersonLoggedIn(string srlId) { bool srlBelongsToPersonLoggedIn = false; //get Id of the member currently logged-in SiteMember sm = IntegrationLoader.LoadDependency <ISiteMembership>("siteMembership").GetMember(); string individualId = ""; if (sm != null && sm.Profile != null && sm.Profile.Id != null) { individualId = sm.Profile.Id.ToString(); } //get list of current SRL's for the member logged-in if (!string.IsNullOrEmpty(individualId)) { SelfReportedLoanListModel srListFromDB = GetSelfReportedLoans(individualId); if (!string.IsNullOrEmpty(srlId) && srListFromDB != null)//only care about loans being updated here. { foreach (SelfReportedLoanModel srlFromDB in srListFromDB.Loans) { if (srlId == srlFromDB.LoanSelfReportedEntryId) { srlBelongsToPersonLoggedIn = true; break; } } if (!srlBelongsToPersonLoggedIn) { _log.Warn(string.Format("User attempted to save loan information that did not belong to them. User = {0}, LoanSelfReportedEntryId = {1}", individualId, srlId)); } } else if (string.IsNullOrEmpty(srlId)) { srlBelongsToPersonLoggedIn = true; } } return(srlBelongsToPersonLoggedIn); }
public static bool ValidateInputSelfReportedLoanList(SelfReportedLoanListModel sr) { bool bValid = false; if (sr != null) { bValid = sr.IsValid(); if (sr.Loans != null) { foreach (SelfReportedLoanModel srl in sr.Loans) { bValid &= ValidateInputSelfReportedLoan(srl); if (!bValid) { break; } } } } return(bValid); }
public ResultCodeModel SaveSelfReportedLoans(SelfReportedLoanListModel srList) { ResultCodeModel insertResult = new ResultCodeModel(); insertResult.ResultCode = 1; ResultCodeModel updateResult = new ResultCodeModel(); updateResult.ResultCode = 1; SelfReportedLoanListModel srInsertList = new SelfReportedLoanListModel(); SelfReportedLoanListModel srUpdateList = new SelfReportedLoanListModel(); //QC 4712: do not save any SRLs that do not belong to the person logged-in. srList = RemoveInvalidLoansFromList(srList); LogSRLData("after RemoveInvalidLoansFromList(srLoans) call", srList); foreach (SelfReportedLoanModel srl in srList.Loans) { if (IsNewSRL(srl)) { srInsertList.Loans.Add(srl); } else { srUpdateList.Loans.Add(srl); } } if (srInsertList.Loans.Count > 0) { insertResult = InsertSelfReportedLoans(srInsertList); } if (srUpdateList.Loans.Count > 0) { updateResult = UpdateSelfReportedLoans(srUpdateList); } ResultCodeModel result = getCombinedResults(insertResult, updateResult, srInsertList.Loans.Count, srUpdateList.Loans.Count); return(result); }
public ResultCodeModel SaveSelfReportedLoans(SelfReportedLoanListModel srLoans) { return(MockJsonLoader.GetJsonObjectFromFile <ResultCodeModel>("SelfReportedService", "SelfReportedLoans")); }
public void LogSRLData(string p, SelfReportedLoanListModel srList) { //throw new NotImplementedException(); }
public static SelfReportedLoanListModel MapGetResponseToModel(GetLoanResponse response, string individualId) { _log.Debug("START MapGetResponseToModel"); SelfReportedLoanListModel loanList = new SelfReportedLoanListModel(); if (response != null) { if (response.LoanCanonical != null && response.LoanCanonical.Length > 0) { for (int i = 0; i < response.LoanCanonical.Length; i++) { _log.Debug("mapping info for ODS Loan with LoanId = " + response.LoanCanonical[i].LoanTier2.LoanInfoType.LoanId); LoanTier2Type tier2 = response.LoanCanonical[i].LoanTier2; //QC 3926: Should only be showing the users loans where "IsArchived" = 'N', and InputSourceId like '%DER%'. if (tier2.LoanInfoType.IsArchived == ASA.Web.Services.LoanService.Proxy.LoanManagement.YNFlagType.N && tier2.LoanInfoType.InputSourceId != null && tier2.LoanInfoType.InputSourceId.ToUpper().Contains("DER") ) { SelfReportedLoanModel srModel = new SelfReportedLoanModel(); srModel.IndividualId = individualId; srModel.AccountNickname = ""; // "Imported Loan " + i; // INFO NOT AVAILALBE ON LOAN. Can be provided by borrower in UI. srModel.HolderName = GetDepartmentName(tier2.OrganizationArray, "HOLD"); //QC 3922: Interest rate is a fraction of 1 in ODS, and needs to display as a whole number in SALT. // Hence, we've added the multiply by 100 here. if (tier2.LoanInfoType.InterestRate != null) { srModel.InterestRate = Math.Round((double)(tier2.LoanInfoType.InterestRate * 100), 3, MidpointRounding.AwayFromZero); } srModel.OriginalLoanAmount = tier2.LoanInfoType.ApprovedLoanAmount; //TODO: is this correct mapping? srModel.IsActive = true; srModel.LoanSelfReportedEntryId = ""; //note: cant give it a PK here... must treat all of these as if they are unsaved SRLE's. srModel.LoanStatusId = tier2.LoanInfoType.LoanStatusId; srModel.LoanTypeId = tier2.LoanInfoType.LoanTypeId; srModel.NextPaymentDueAmount = tier2.RepaymentInfoType.NextPaymentDueAmount; srModel.NextPaymentDueDate = tier2.RepaymentInfoType.NextPaymentDueDate; srModel.PaymentDueAmount = tier2.RepaymentInfoType.NextPaymentDueAmount; srModel.PrincipalBalanceOutstandingAmount = tier2.LoanInfoType.OutstandingPrincipalBalance; srModel.SchoolName = GetDepartmentName(tier2.OrganizationArray, "SCHL"); srModel.ServicerName = GetDepartmentName(tier2.OrganizationArray, "SERV"); srModel.ServicerWebAddress = ""; //is there something I don't know about that can provide this info?? srModel.LoanTerm = 10; //defaulting to 10 for now. Will likely get more requirements for future releases. loanList.Loans.Add(srModel); } } } else if (response.ResponseMessageList != null && response.ResponseMessageList.Count > 0) { for (int i = 0; i < response.ResponseMessageList.Count; i++) { _log.Info("ResponseMessageList[" + i + "].MessageDetails = " + response.ResponseMessageList[i].MessageDetails); ErrorModel error = new ErrorModel(response.ResponseMessageList[i].MessageDetails, "Web Loan Service", response.ResponseMessageList[i].ResponseCode); loanList.ErrorList.Add(error); } } else { _log.Warn("An error occured in MapGetResponseToModel when trying to retrieve loan information. Canonical not found."); ErrorModel error = new ErrorModel("An error occured when trying to retrieve loan information", "Web Loan Service"); loanList.ErrorList.Add(error); } } else { ErrorModel error = new ErrorModel("No valid response was received from the Loan Management service", "Web Loan Service"); loanList.ErrorList.Add(error); } _log.Debug("END MapGetResponseToModel"); return(loanList); }
/// <summary> /// To the member reported loan contract list. /// </summary> /// <param name="loans">The loans.</param> /// <returns></returns> public static MemberReportedLoanContract[] ToMemberReportedLoanContractList(this SelfReportedLoanListModel loans) { return(loans.Loans.Select(loan => loan.ToMemberReportedLoanContract()).ToArray()); }
public static SelfReportedLoanListModel MapXmlNodeToSelfReportedLoanList(XmlNode node) { SelfReportedLoanListModel srList = new SelfReportedLoanListModel(); if (node != null) { foreach (XmlNode n in node.ChildNodes) //foreach SRL returned { SelfReportedLoanModel srl = new SelfReportedLoanModel(); foreach (XmlNode field in n.ChildNodes)//map the fields { if (field.InnerText != null && field.InnerText.Length > 0) { try { switch (field.Name) { case "a07_key": srl.LoanSelfReportedEntryId = field.InnerText; break; case "a07_ind_cst_key": srl.IndividualId = field.InnerText; break; case "a07_loan_type": srl.LoanTypeId = field.InnerText; break; case "a07_loan_status": srl.LoanStatusId = field.InnerText; break; case "a07_account_nickname": srl.AccountNickname = field.InnerText; break; case "a07_holder_name": srl.HolderName = field.InnerText; break; case "a07_school_name": srl.SchoolName = field.InnerText; break; case "a07_servicer_name": srl.ServicerName = field.InnerText; break; case "a07_servicer_url": srl.ServicerWebAddress = field.InnerText; break; case "a07_principal_balance_outstanding_amount": srl.PrincipalBalanceOutstandingAmount = Decimal.Parse(field.InnerText); break; case "a07_payment_due_amount": srl.PaymentDueAmount = Decimal.Parse(field.InnerText); break; case "a07_next_payment_due_amount": srl.NextPaymentDueAmount = Decimal.Parse(field.InnerText); break; case "a07_next_payment_due_date": srl.NextPaymentDueDate = DateTime.Parse(field.InnerText); break; case "a07_active_flag": int active = Int32.Parse(field.InnerText); if (active == 1) { srl.IsActive = true; } else { srl.IsActive = false; } break; case "a07_interest_rate": srl.InterestRate = Double.Parse(field.InnerText); break; case "a07_received_year": srl.ReceivedYear = Int32.Parse(field.InnerText); break; case "a07_original_loan_amount": srl.OriginalLoanAmount = Decimal.Parse(field.InnerText); break; case "a07_loan_record_source": srl.LoanSource = field.InnerText; break; case "a07_loan_term": srl.LoanTerm = Int32.Parse(field.InnerText); break; case "a07_add_date": srl.DateAdded = DateTime.Parse(field.InnerText); break; default: break; } //switch } //try catch (Exception e) { //something went wrong? } } //if } //for srList.Loans.Add(srl); } //for } //if else { srList.ErrorList.Add(new ErrorModel("Problem querying Avectra. Make sure your search criteria was valid.")); } return(srList); }