static void Main(string[] args) { try { string commandType = args[0]; switch (commandType) { case "GET": { string userID = args[1]; string password = args[2]; string loanID = args[3]; GetLoan(userID, password, loanID); break; } case "PUT": { string json = args[1]; UpdateLoanRequest request = JsonConvert.DeserializeObject <UpdateLoanRequest>(json); PutLoan(request); break; } case "POST": { string json = args[1]; PostNewLoanRequest request = JsonConvert.DeserializeObject <PostNewLoanRequest>(json); PostLoan(request); break; } default: { OutputResult($"Command Type : { args[0] } is invalid."); break; } } } catch (Exception ex) { OutputResult(ex.ToString()); } }
public async Task <IActionResult> EditAsync(UpdateLoanViewModel model) { if (!ModelState.IsValid) { return(RedirectToAction("DetailsView", new { Area = "Loan", uid = model.UID, errorMessage = $"{GlobalConstants.ERROR_ACTION_PREFIX} update {ENTITY_NAME} details." })); } LoanResponse _Loan = await __LoanManager.GetByUIDAsync(model.UID); if (_Loan == null) { return(RedirectToAction("DetailsView", new { Area = "Loan", uid = model.UID, errorMessage = $"{GlobalConstants.ERROR_ACTION_PREFIX} find {ENTITY_NAME} details." })); } UpdateLoanRequest _Request = new UpdateLoanRequest { UID = model.UID, FromTimestamp = model.StartTimestamp, ExpiryTimestamp = model.ExpiryTimestamp, AcceptedTermsAndConditions = model.AcceptedTermsAndConditions }; if (model.AcceptedTermsAndConditions) { if (_Loan.Status == Enums.Loan.Status.Pending) { if (model.StartTimestamp <= DateTime.Now) { _Request.Status = Enums.Loan.Status.ActiveLoan; } else { _Request.Status = Enums.Loan.Status.InactiveLoan; } } } BaseResponse _Response = await __LoanManager.UpdateAsync(_Request); if (!_Response.Success) { return(RedirectToAction("DetailsView", new { Area = "Loan", uid = model.UID, errorMessage = $"{GlobalConstants.ERROR_ACTION_PREFIX} update {ENTITY_NAME} details." })); } return(RedirectToAction("DetailsView", new { Area = "Loan", uid = model.UID, successMessage = $"{GlobalConstants.SUCCESS_ACTION_PREFIX} updated {ENTITY_NAME} details." })); }
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(); } }