protected void filterLoan() { // 1.- Get the latest datasource allLoans = (List <LoanDTO>)ViewState["allLoans"]; // 2.- Filter by Region is value is not -1 if (DropDownSection.SelectedValue != "-1") { allLoans = BLoan.FilterBySection(allLoans, DropDownSection.SelectedItem.Text); } // 3.- Filter by loan date if it is a valid date DateTime result; if (DateTime.TryParse(TextBoxLoan.Text, out result)) { allLoans = BLoan.filterByLoanDate(allLoans, Convert.ToDateTime(TextBoxLoan.Text)); } // 4.- Filter by delivery date if it is a valid date if (DateTime.TryParse(TextBoxDelivery.Text, out result)) { allLoans = BLoan.filterByDeliveryDate(allLoans, Convert.ToDateTime(TextBoxDelivery.Text)); } // 5.- Filter by Keyword allLoans = BLoan.filterByKeyWord(allLoans, TextBoxSearch.Text); // 6.- Bind grid to datasource and save it in viewstate ViewState["filterAllLoans"] = allLoans; GridListLoans.DataSource = allLoans; GridListLoans.DataBind(); }
protected void InsertLoan_Click(object sender, EventArgs e) { if (userIdValidation.IsValid && copyIdValidation.IsValid) { DataLibrary.Loan loan = new DataLibrary.Loan(); // Get values from controls loan.CopyId = Convert.ToInt32(boxCopyId.Text); loan.UserId = Convert.ToInt32(boxUserId.Text); DateTime deliveryD = DateTime.ParseExact(boxDelivery.Text, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture); loan.DeliveryDate = Convert.ToDateTime(deliveryD); DateTime loanD = DateTime.ParseExact(boxLoanDate.Text, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture); loan.LoanDate = Convert.ToDateTime(loanD); try { // Insert Loan int loanId = BLoan.insert(loan); // Goest to mainLisLoan Response.Redirect("~/Loan/MainListLoan.aspx"); } catch (Exception generalException) { PanelInsertLoan.Visible = true; LiteralInsertLoan.Text = generalException.Message; } } }
protected void ButDelete_Click(object sender, EventArgs e) { // Delete de loan BLoan.deleteById(loanId); // Go to loan main list Response.Redirect("~/Loan/MainListLoan.aspx"); }
/// <summary> /// Post a Lending Application to Blend /// </summary> /// <param name="loan"></param> /// <returns></returns> public async Task <BLoan> PostLendingAppAsync(BLoan loan) { Logger.LogInformation("Sending Lending Application to Blend"); try { var req = new HttpRequestMessage(HttpMethod.Post, config.BasePath + config.URILendingApplication); req = AddDefaultHeaders(req); var requestPayload = JsonConvert.SerializeObject(loan, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); req.Content = new StringContent(requestPayload, System.Text.Encoding.UTF8, "application/json"); HttpResponseMessage response = await _httpClient.SendAsync(req); if (response.StatusCode != System.Net.HttpStatusCode.OK) { Logger.LogError("Blend request: {0}-{1}", response.StatusCode, response.ReasonPhrase); throw new SystemException("Failure result in processing loan application with Blend"); } var loanResponse = await response.Content.ReadFromJsonAsync <Models.Blend.BLoan>(); Logger.LogInformation("Loan {0} created.", loanResponse.Id); return(loanResponse); } catch (HttpRequestException e) { Logger.LogError(e, "Failure in processing Loan Application to Blend"); throw new SystemException("Failure in processing loan application with Blend. Please retry later.", e); } catch (SystemException e) { throw; } catch (Exception e) { Logger.LogError(e, "Unexpected Failure in processing Loan Application to Blend"); throw; } }
protected void ButUpdate_Click(object sender, EventArgs e) { // Get the loanId to update loanId = Convert.ToInt32(Request.QueryString["loanId"]); // Get the loan by id DataLibrary.Loan loan = new DataLibrary.Loan(); loan = BLoan.getById(loanId); // Set values to update from fields and update loan record DateTime deliveryD = DateTime.ParseExact(boxDelivery.Text, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture); loan.DeliveryDate = Convert.ToDateTime(deliveryD); DateTime loanD = DateTime.ParseExact(boxLoanDate.Text, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture); loan.LoanDate = Convert.ToDateTime(loanD); BLoan.update(loan); // Go to main list page Response.Redirect("~/Loan/MainListLoan.aspx"); }