private SilkTitleOrderResponse OrderSilkTitle(Loan loan) { var currentUser = EncompassApplication.CurrentUser; if (SilkUtility.ValidateAllSilkFields(loan, out var msgForUser) == false) { loan.Fields["CX.SILK.ERRORMSG"].Value = $"Title could not be ordered. The following fields were missing: {msgForUser}"; return(new SilkTitleOrderResponse() { WasSuccessful = false, ErrorMessage = msgForUser }); } var titleRequest = SilkUtility.MapLoanToSilkTitleOrderRequest(loan); var silkTitleContainerUri = SilkSettings.PostTitleOrderToSilkUrl; //send to Silk var titleResponse = SilkUtility.PostTitleOrderToSilk(loan, silkTitleContainerUri, titleRequest); if (!titleResponse.WasSuccessful) { loan.Fields["CX.SILK.ERRORMSG"].Value = titleResponse.ErrorMessage; throw new Exception("Error posting title Order to Silk" + $"Error:{titleResponse.ErrorMessage}." + Environment.NewLine + "Please submit a Help Desk Ticket"); } loan.Fields["187"].Value = titleResponse.Id; loan.Fields["CX.PRWK.TITL.ORD"].Value = DateTime.Now; loan.Fields["CX.PRWK.TITL.BY"].Value = currentUser.FullName; return(titleResponse); }
private bool PostPreliminaryTitleOrderDocsToSilk(Loan loan, string orderId, out string msgForUser) { string docName = ""; string postDocToSilkUri = SilkSettings.PostDocToSilkUrl; //grab 1003 and title quote from eFolder List <B64SilkDocument> docsToPost = new List <B64SilkDocument>(); int bpCount = loan.BorrowerPairs.Count; //if borrower pair count is greater than 1 we need to grab all 1003s on the file - otherwise just want to get the latest attachment if (bpCount > 1) { List <Attachment> signed1003 = GetAttachmentForEachBorrowerPair(loan, "Disclosures - Signed 1003"); if (signed1003 == null) { throw new Exception("Error posting 1003 to Silk. Document is not in File!"); } foreach (var att in signed1003) { B64SilkDocument doc = new B64SilkDocument { Name = att.Title + ".pdf", Base64EncodedSilkDocument = Convert.ToBase64String(att.DataOriginal), FieldIdToSet = loan.Fields["CX.SILK.1003.UPLOAD.DATE"], Type = "1003" }; docsToPost.Add(doc); } } else { Attachment signed1003 = SilkUtility.GetLatestAttachment(loan, "Disclosures - Signed 1003", docName); if (signed1003 == null) { throw new Exception("Error posting 1003 to Silk. Document is not in File!"); } B64SilkDocument doc = new B64SilkDocument { Name = signed1003.Title + ".pdf", Base64EncodedSilkDocument = Convert.ToBase64String(signed1003.DataOriginal), FieldIdToSet = loan.Fields["CX.SILK.1003.UPLOAD.DATE"], Type = "1003" }; docsToPost.Add(doc); } Attachment titleQuoteFromEncompass = SilkUtility.GetLatestAttachment(loan, "Title Fee Estimate", docName); if (titleQuoteFromEncompass == null) { throw new Exception("Error posting Tax Quote to Silk. Document is not in File!"); } B64SilkDocument titleQuote = new B64SilkDocument { Name = titleQuoteFromEncompass.Title, Base64EncodedSilkDocument = Convert.ToBase64String(titleQuoteFromEncompass.DataOriginal), FieldIdToSet = loan.Fields["CX.SILK.FEE.UPLOAD.DATE"], Type = "Estimated Title Fees" }; docsToPost.Add(titleQuote); foreach (B64SilkDocument doc in docsToPost) { var docRequest = SilkUtility.MapLoanToPostSilkDocumentRequest(loan, doc, orderId); var docResponse = SilkUtility.PostDocumentToSilk(postDocToSilkUri, docRequest); if (!docResponse.WasSuccessful) { //need to do something if not successful loan.Fields["CX.SILK.DOC.UPLOAD.ERRORMSG"].Value = docResponse.ErrorMessage; msgForUser = docResponse.ErrorMessage; return(false); } doc.FieldIdToSet.Value = DateTime.Now; } msgForUser = "******"; return(true); }