private static void PutLoan(UpdateLoanRequest request) { try { PointUserLoginResults loginResult = CreateSession(request.userName, request.password); LoanInfo loanInfo = GetLoanInfo(loginResult, request.loanID); if (loanInfo != null) { LoanFile loanFile = loanInfo.Open(false); foreach (LoanField loanField in request.loanFields) { Bind_FieldID_Name(); int fieldID = GetFieldID(loanField.fieldName.ToLower().Trim()); if (fieldID > 0) { BorrowerSetPositionType positionType = (BorrowerSetPositionType)loanField.borrowerPosition; loanFile.SetData(fieldID, BorrowerSetPositionType.Borrower, loanField.fieldValue); } else { OutputResult($"The field name : { loanField.fieldName } is invalid."); return; } } loanFile.Save(); loanFile.Close(); OutputResult($"Loan Updated Successfully With LoanFile Name : { loanFile.Info.Attributes.FileName}"); } else { string message = $"loanID : { request.loanID } is invalid or doesn't exists."; OutputResult(message); } } catch (Exception ex) { throw ex; } finally { CloseSession(); } }
private static void PostLoan(PostNewLoanRequest request) { try { PointUserLoginResults loginResult = CreateSession(request.userName, request.password); string loanFileName = Guid.NewGuid().ToString(); DataFolderInfo dataFolder = loginResult.UserInfo.DataFolders.FirstOrDefault(); if (dataFolder != null) { LoanFile loanFile = LoanInfo.Create(Calyx.Point.Data.Common.LoanType.Borrower); foreach (LoanField loanField in request.loanFields) { Bind_FieldID_Name(); int fieldID = GetFieldID(loanField.fieldName.ToLower().Trim()); if (fieldID > 0) { BorrowerSetPositionType positionType = (BorrowerSetPositionType)loanField.borrowerPosition; loanFile.SetData(fieldID, BorrowerSetPositionType.Borrower, loanField.fieldValue); } else { OutputResult($"The field name : { loanField.fieldName } is invalid."); return; } } loanFile.Save(loanFileName, dataFolder); loanFile.Close(); OutputResult($"Loan Created Successfully With LoanFile Name : { loanFile.Info.Attributes.FileName }"); } } catch (Exception ex) { throw ex; } finally { CloseSession(); } }
private static void GetLoan(string userID, string password, string loanID) { try { PointUserLoginResults loginResult = CreateSession(userID, password); LoanInfo loanInfo = GetLoanInfo(loginResult, loanID); if (loanInfo != null) { LoanFile loanFile = loanInfo.Open(true); XmlDocument xmlResult = loanFile.ToMismo(); loanFile.Close(); string result = ""; using (var stringWriter = new StringWriter()) { using (var xmlTextWriter = XmlWriter.Create(stringWriter)) { xmlResult.WriteTo(xmlTextWriter); xmlTextWriter.Flush(); result = stringWriter.GetStringBuilder().ToString(); } } OutputResult(result); } else { string message = $"loanID : { loanID } is invalid or doesn't exists."; OutputResult(message); } } catch (Exception ex) { throw ex; } finally { CloseSession(); } }