public async Task <ActionResult <LoanFile> > PostLoan(LoanFile loan) { _context.LoanFiles.Add(loan); await _context.SaveChangesAsync(); return(CreatedAtAction("GetLoan", new { id = loan.Id }, loan)); }
private dynamic BindUpLoanInfo(LoanInfo loan) { dynamic loanInfo = new System.Dynamic.ExpandoObject(); LoanFile loanFile = loan.Open(true); List <LoanAttribute> _attrs = CalyxConnEngine.Attributes; if (_attrs == null || _attrs.Count() == 0) { loanInfo.Error = "OOPS! Failed to Bind Loan Fields."; } else { loanInfo.Error = ""; List <PointField> pointFields = new List <PointField>(); foreach (LoanAttribute attr in _attrs) { try { pointFields.Add(new PointField() { PointFieldID = attr.PointFieldID, Description = attr.PointFieldName, Data = PointFieldValue(loanFile.GetData(attr.PointFieldID, Calyx.Point.Data.Common.BorrowerSetPositionType.Borrower)) }); } catch { } } loanInfo.PointFields = pointFields; } return(loanInfo); }
public async Task <IActionResult> PutLoan(long id, LoanFile loan) { if (id != loan.Id) { return(BadRequest()); } _context.Entry(loan).State = EntityState.Modified; await _context.SaveChangesAsync(); return(NoContent()); }
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(); } }