public Task <ConsumerLoanFulfillmentArrangementResponse> RetrieveConsumerLoanFulfillmentArrangementWithBQsAsync(string cr_reference_id) { return(Task.Run((Func <ConsumerLoanFulfillmentArrangementResponse>)(() => { var loanId = ParseGuid(cr_reference_id, "cr_reference_id"); var loan = _cdsWebApi.Retrieve("msfsi_financialproducts", loanId, "msfsi_loantype", "_msfsi_customerid_value", "msfsi_outstandingtotalamount", "msfsi_loanmaturitydate", "msfsi_loanstartdate", "msfsi_interestrate", "statecode"); var response = new ConsumerLoanFulfillmentArrangementResponse() { LoanType = loan.Attributes.ContainsKey("*****@*****.**") ? loan.Attributes["*****@*****.**"]?.ToString() : "", CustomerReference = loan.Attributes["_msfsi_customerid_value"]?.ToString(), LoanOutstandingBalance = loan.Attributes["msfsi_outstandingtotalamount"]?.ToString(), LoanMaturityDate = FormatDateString(loan.Attributes["msfsi_loanmaturitydate"]?.ToString()), LoanOriginationDate = FormatDateString(loan.Attributes["msfsi_loanstartdate"]?.ToString()), LoanStatus = loan.Attributes["statecode"]?.ToString() == "0" ? "active" : "inactive", ProductInstanceReference = loanId.ToString(), }; var unformattedInterestRate = loan.Attributes["msfsi_interestrate"]?.ToString(); if (string.IsNullOrEmpty(unformattedInterestRate) == false) { response.LoanApplicableRate = $"{unformattedInterestRate}%"; } return response; }))); }
public Task <RecordCollateralAssetAdministrativePlanResponse> RecordCollateralAssetAdministrativePlanAsync(string cr_reference_id, RecordCollateralAssetAdministrativePlanRequest body) { return(Task.Run <RecordCollateralAssetAdministrativePlanResponse>(() => { var collateral = new CdsEntity(); if (Guid.TryParse(cr_reference_id, out Guid collateralId) == false) { throw new Exception(_invalidCrReferenceIdError); } else { collateral.Id = collateralId; } if (string.IsNullOrEmpty(body.EmpolyeeBusinessUnitReference) == false) { if (Guid.TryParse(body.EmpolyeeBusinessUnitReference, out var businessUnitId) == false) { throw new Exception("EmpolyeeBusinessUnitReference must be specified as a valid GUID"); } else { var businessUnit = _cdsWebApi.Retrieve("businessunits", businessUnitId, "name"); collateral.Attributes["msfsi_evaluatedby"] = $"{businessUnit.Attributes["name"]} Team"; } } if (string.IsNullOrEmpty(body.RecordingRecordDateTime) == false) { if (DateTime.TryParse(body.RecordingRecordDateTime, out var recordingDateTime) == false) { throw new Exception("RecordingRecordDateTime must be specified as a valid DateTime"); } else { collateral.Attributes["msfsi_dateofvaluation"] = recordingDateTime; collateral.Attributes["msfsi_nextdateofvaluation"] = recordingDateTime.AddYears(1); } } if (string.IsNullOrEmpty(body.RecordingRecordType) == false) { collateral.Attributes["msfsi_description"] = body.RecordingRecordType; } if (collateral.Attributes.Count > 0) { _cdsWebApi.Update("msfsi_collaterals", collateral); } return new RecordCollateralAssetAdministrativePlanResponse() { RecordingRecordReference = collateral.Id.ToString(), RecordingRecordStatus = "Applied" }; })); }