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); }
private ASAMemberModel RetrieveASAMemberModel(Object memberId, Dictionary <String, Object> providerKeys = null) { ASAMemberModel model = null; Object membershipId = null; //Minor hack on top of the email hack to ensure the correct ID's are being used for storage of objects into other stores //BIG TODO : Cleaner implmentation of get user that allows both email and ID to work without conflicting calls and types //will likely require some kind of credential key object. String memberIdKey = "ASAMemberId[" + memberId.ToString() + "]"; if (memberId.ToString().IndexOf('@') == -1) { membershipId = memberId; } else { if (HttpContext.Current.Items[memberIdKey] != null) { membershipId = HttpContext.Current.Items[memberIdKey]; } } String logMethodName = ".RetrieveASAMemberModel(Object memberId, Dictionary<String, Object> providerKeys = null) - "; _log.Debug(logMethodName + "Begin Method"); _log.Debug(logMethodName + "Getting ASAMemberModel for memberId : " + memberId); String modelKey = "ASAMemberModel[" + membershipId + "]"; String modelLoadedKey = "ASAMemberModelLoaded[" + membershipId + "]"; Boolean modelLoaded = false; if (membershipId != null && HttpContext.Current.Items[modelLoadedKey] != null) { Boolean.TryParse(HttpContext.Current.Items[modelLoadedKey].ToString(), out modelLoaded); } if (modelLoaded) { _log.Debug(logMethodName + "Trying to load from Request persistence."); model = HttpContext.Current.Items[modelKey] as ASAMemberModel; _log.Debug(logMethodName + "ASAMemberModel Loaded from Request persistence"); } else { _log.Debug(logMethodName + "ASAMemberModel NOT FOUND in Request persistence. Querying Avectra."); AsaMemberAdapter adapter = new AsaMemberAdapter(); //TODO - JHL: Added for demo only if (memberId.ToString().IndexOf('@') == -1) { Guid systemId; if (Guid.TryParse(memberId.ToString(), out systemId) && systemId != Guid.Empty) { _log.Debug(logMethodName + "Calling AsaMemberAdapter.GetMember(Guid systemId) - memberId = '" + systemId.ToString() + "'"); model = adapter.GetMember(systemId); if (model != null) { if (!HttpContext.Current.Items.Contains("MembershipId")) { HttpContext.Current.Items.Add("MembershipId", model.MembershipId); } } _log.Debug(logMethodName + "Call to AsaMemberAdapter.GetMember(Guid systemId) COMPLETED - memberId = '" + systemId.ToString() + "'"); } else if (providerKeys != null) { if (providerKeys["IndividualId"] != null) { _log.Debug(logMethodName + "Calling AsaMemberAdapter.GetMember(Guid systemId) - individualId = '" + systemId.ToString() + "'"); model = adapter.GetMember(new Guid((string)providerKeys["IndividualId"])); _log.Debug(logMethodName + "Call to AsaMemberAdapter.GetMember(Guid systemId) COMPLETED - individualId = '" + systemId.ToString() + "'"); } else if (providerKeys["ActiveDirectoryKey"] != null && Guid.TryParse(providerKeys["ActiveDirectoryKey"].ToString(), out systemId) && systemId != Guid.Empty) { _log.Debug(logMethodName + "Calling AsaMemberAdapter.GetMember(Guid systemId) - memberId from ProviderKeys = '" + systemId.ToString() + "'"); model = adapter.GetMember(systemId); _log.Debug(logMethodName + "Call to AsaMemberAdapter.GetMember(Guid systemId) COMPLETED - memberId from ProviderKeys= '" + systemId.ToString() + "'"); } } } else { _log.Debug(logMethodName + "Calling AsaMemberAdapter.GetMemberByEmail(String email) - email = '" + memberId.ToString() + "'"); model = adapter.GetMemberByEmail(memberId.ToString()); _log.Debug(logMethodName + "Call to AsaMemberAdapter.GetMemberByEmail(String email) COMPLETED - email = '" + memberId.ToString() + "'"); } //cov-10328 - check for nulls if (model != null) { membershipId = model.ActiveDirectoryKey; memberIdKey = "ASAMemberId[" + model.Emails.FirstOrDefault(m => m.IsPrimary == true).EmailAddress + "]"; modelKey = "ASAMemberModel[" + membershipId.ToString() + "]"; modelLoadedKey = "ASAMemberModelLoaded[" + membershipId.ToString() + "]"; HttpContext.Current.Items[memberIdKey] = memberId; HttpContext.Current.Items[modelKey] = model; HttpContext.Current.Items[modelLoadedKey] = true; _log.Debug(logMethodName + "ASAMemberModel Loaded into Request persistence"); } else { //allocate empty model model = new ASAMemberModel(); _log.Warn(logMethodName + "ASAMemberModel NOT Loaded into Request persistence"); } } _log.Debug(logMethodName + "End Method"); return(model); }