/// <summary> /// Fill method for populating an entire collection of CreditScores /// </summary> public virtual void Fill(CreditScores creditScores) { // create the connection to use SqlConnection cnn = new SqlConnection(CreditScore.GetConnectionString()); try { using (cnn) { // open the connection cnn.Open(); // create an instance of the reader to fill. SqlDataReader datareader = SqlHelper.ExecuteReader(cnn, "gsp_SelectCreditScores"); // Send the collection and data to the object factory CreateObjectsFromData(creditScores, datareader); // close the connection cnn.Close(); } // nullify the connection cnn = null; } catch (SqlException sqlex) { throw sqlex; } }
/// <summary> /// The object factory for a particular data collection instance. /// </summary> public virtual void CreateObjectsFromData(CreditScores creditscores, System.Data.DataSet data) { // Do nothing if we have nothing if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0) { return; } // Create a local variable for the new instance. CreditScore newobj = null; // Create a local variable for the data row instance. System.Data.DataRow dr = null; // Iterate through the table rows for (int i = 0; i < data.Tables[0].Rows.Count; i++) { // Get a reference to the data row dr = data.Tables[0].Rows[i]; // Create a new object instance newobj = System.Activator.CreateInstance(creditscores.ContainsType[0]) as CreditScore; // Let the instance set its own members newobj.SetMembers(ref dr); // Add the new object to the collection instance creditscores.Add(newobj); } }
public IResult Update(CreditScore entity) { var newCredit = CalculateCreditScore(entity).Data; _creditScoreDal.Update(newCredit); return(new SuccessResult(Messages.CreditScoreUpdated)); }
private void LVScores_SelectionChanged(object sender, SelectionChangedEventArgs e) { bool enabled = LVScores.SelectedIndex >= 0; _selectedScore = enabled ? (CreditScore)LVScores.SelectedItem : new CreditScore(); BtnDeleteCreditScore.IsEnabled = enabled; BtnModifyCreditScore.IsEnabled = enabled; }
public IActionResult Update(CreditScore creditScore) { var result = _creditScoreService.Update(creditScore); if (result.Success) { return(Ok(result)); } else { return(BadRequest(result)); } }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (CreditProfileDate != null) { hashCode = hashCode * 59 + CreditProfileDate.GetHashCode(); } if (CreditRiskRating != null) { hashCode = hashCode * 59 + CreditRiskRating.GetHashCode(); } if (CreditScore != null) { hashCode = hashCode * 59 + CreditScore.GetHashCode(); } if (ValidFor != null) { hashCode = hashCode * 59 + ValidFor.GetHashCode(); } if (TagCreditScoring != null) { hashCode = hashCode * 59 + TagCreditScoring.GetHashCode(); } if (TagCreditLimit != null) { hashCode = hashCode * 59 + TagCreditLimit.GetHashCode(); } if (TagCreditThreshold != null) { hashCode = hashCode * 59 + TagCreditThreshold.GetHashCode(); } if (TagCreditOnHold != null) { hashCode = hashCode * 59 + TagCreditOnHold.GetHashCode(); } if (TagContractDailyCreditLimit != null) { hashCode = hashCode * 59 + TagContractDailyCreditLimit.GetHashCode(); } if (TagContractPeriodicCreditLimit != null) { hashCode = hashCode * 59 + TagContractPeriodicCreditLimit.GetHashCode(); } return(hashCode); } }
/// <summary>Adds a new <see cref="CreditScore"/> to the database.</summary> /// <param name="newScore"><see cref="CreditScore"/> to be added</param> /// <returns>True if successful</returns> public Task <bool> AddCreditScore(CreditScore newScore) { SQLiteCommand cmd = new SQLiteCommand { CommandText = "INSERT INTO CreditScores([Date], [Source], [Score], [Provider], [FICO])VALUES(@date, @source, @score, @provider, @fico)" }; cmd.Parameters.AddWithValue("@date", newScore.DateToString); cmd.Parameters.AddWithValue("@source", newScore.Source); cmd.Parameters.AddWithValue("@score", newScore.Score); cmd.Parameters.AddWithValue("@provider", newScore.ProviderToString); cmd.Parameters.AddWithValue("@fico", Int32Helper.Parse(newScore.FICO)); return(SQLiteHelper.ExecuteCommand(_con, cmd)); }
/// <summary>Deletes a <see cref="CreditScore"/> from the database</summary> /// <param name="deleteScore"><see cref="CreditScore"/> to be deleted</param> /// <returns>True if successful</returns> public Task <bool> DeleteCreditScore(CreditScore deleteScore) { SQLiteCommand cmd = new SQLiteCommand { CommandText = "DELETE FROM CreditScores WHERE [Date] = @date AND [Source] = @source AND [Score] = @score AND [Provider] = @provider AND [FICO] = @fico" }; cmd.Parameters.AddWithValue("@date", deleteScore.DateToString); cmd.Parameters.AddWithValue("@source", deleteScore.Source); cmd.Parameters.AddWithValue("@score", deleteScore.Score); cmd.Parameters.AddWithValue("@provider", deleteScore.ProviderToString); cmd.Parameters.AddWithValue("@fico", Int32Helper.Parse(deleteScore.FICO)); return(SQLiteHelper.ExecuteCommand(_con, cmd)); }
public CreditScore CreditRecordFind(string UserID, string TrainingID) { try { String stmtId = "CreditRecord_Find"; Hashtable ht = new Hashtable(); ht.Add("UserID", UserID); ht.Add("TrainingID", TrainingID); CreditScore result = ExecuteQueryForObject <CreditScore>(stmtId, ht); return(result); } catch (Exception ex) { return(null); } }
/// <summary> /// Deletes the object. /// </summary> public virtual void Delete(CreditScore deleteObject) { // create a new instance of the connection SqlConnection cnn = new SqlConnection(CreditScore.GetConnectionString()); // create local variable array for the sql parameters SqlParameterHash sqlparams = null; try { // discover the parameters sqlparams = SqlHelperParameterCache.GetSpParameterSet(CreditScore.GetConnectionString(), "gsp_DeleteCreditScore"); // Store the parameter for the CreditScoreID attribute. sqlparams["@creditScoreID"].Value = deleteObject.CreditScoreID; using (cnn) { // open the connection cnn.Open(); // Execute the stored proc to perform the delete on the instance. SqlHelper.ExecuteNonQuery(cnn, CommandType.StoredProcedure, "gsp_DeleteCreditScore", sqlparams); // close the connection after usage cnn.Close(); } // nullify the connection var cnn = null; } catch (SqlException sqlex) { throw sqlex; } // nullify the reference deleteObject = null; }
/// <summary> /// Fills a single instance with data based on its primary key values. /// </summary> public virtual void Fill(CreditScore creditscore, System.Int64 creditScoreID) { // create the connection to use SqlConnection cnn = new SqlConnection(CreditScore.GetConnectionString()); try { // discover the sql parameters SqlParameterHash sqlparams = SqlHelperParameterCache.GetSpParameterSet(CreditScore.GetConnectionString(), "gsp_SelectCreditScore"); using (cnn) { // open the connection cnn.Open(); // set the parameters sqlparams["@creditScoreID"].Value = creditScoreID; // create an instance of the reader to fill. SqlDataReader datareader = SqlHelper.ExecuteReader(cnn, "gsp_SelectCreditScore", sqlparams); if (datareader.Read()) { creditscore.SetMembers(ref datareader); } cnn.Close(); // close the connection } // nullify the connection var cnn = null; } catch (SqlException sqlex) { throw sqlex; } }
/// <summary> /// Fill method for populating a collection by CreditScoreExclusionReasonType /// </summary> public void FillByCreditScoreExclusionReasonType(CreditScores creditScores, System.Int16 id) { // create the connection to use SqlConnection cnn = new SqlConnection(CreditScore.GetConnectionString()); try { // discover the sql parameters SqlParameterHash sqlparams = SqlHelperParameterCache.GetSpParameterSet(CreditScore.GetConnectionString(), "gsp_SelectCreditScoresByCreditScoreExclusionReasonType"); using (cnn) { // open the connection cnn.Open(); // set the parameters sqlparams["@creditScoreExclusionType"].Value = id; // create an instance of the reader to fill. SqlDataReader datareader = SqlHelper.ExecuteReader(cnn, "gsp_SelectCreditScoresByCreditScoreExclusionReasonType", sqlparams); // Send the collection and data to the object factory. CreateObjectsFromData(creditScores, datareader); // close the connection cnn.Close(); } // nullify the connection cnn = null; } catch (SqlException sqlex) { throw sqlex; } }
/// <summary>Modifies a <see cref="CreditScore"/> in the database.</summary> /// <param name="oldScore">Original <see cref="CreditScore"/></param> /// <param name="newScore">Modified <see cref="CreditScore"/></param> /// <returns>True if successful</returns> public Task <bool> ModifyCreditScore(CreditScore oldScore, CreditScore newScore) { SQLiteCommand cmd = new SQLiteCommand { CommandText = "UPDATE CreditScores SET [Date] = @date, [Source] = @source, [Score] = @score, [Provider] = @provider, [FICO] = @fico WHERE [Date] = @oldDate AND [Source] = @oldSource AND [Score] = @oldScore AND [Provider] = @oldProvider AND [FICO] = @oldFico" }; cmd.Parameters.AddWithValue("@date", newScore.DateToString); cmd.Parameters.AddWithValue("@source", newScore.Source); cmd.Parameters.AddWithValue("@score", newScore.Score); cmd.Parameters.AddWithValue("@provider", newScore.ProviderToString); cmd.Parameters.AddWithValue("@fico", Int32Helper.Parse(newScore.FICO)); cmd.Parameters.AddWithValue("@oldDate", oldScore.DateToString); cmd.Parameters.AddWithValue("@oldSource", oldScore.Source); cmd.Parameters.AddWithValue("@oldScore", oldScore.Score); cmd.Parameters.AddWithValue("@oldProvider", oldScore.ProviderToString); cmd.Parameters.AddWithValue("@oldFico", Int32Helper.Parse(oldScore.FICO)); return(SQLiteHelper.ExecuteCommand(_con, cmd)); }
/// <summary> /// Resets the StateManager to the default state. Use this when /// the player's session needs to be reset. The StateManger is /// set up for a "fresh" playthrough. /// </summary> public static void resetToDefaultState() { cashOnHand = DefaultState.cashOnHand; loanList.Clear(); income.Clear(); nextID = DefaultState.nextID; timesEntered = DefaultState.timesEntered; totalFloorsVisited = DefaultState.totalFloorsVisited; currentFloor = DefaultState.currentFloor; scoreChangeFactor = DefaultState.scoreChangeFactor; lastCreditScore = 0; creditScore = DefaultState.creditScore; paymentStreak = DefaultState.paymentStreak; cashOnEntrance = DefaultState.cashOnEntrance; sawEntryTutorial = DefaultState.sawEntryTutorial; inStoryTutorial = DefaultState.inStoryTutorial; destroyAllSingletons(); pauseAvailable = DefaultState.pauseAvailable; playerDead = DefaultState.playerDead; playerWon = DefaultState.playerWon; startedFromDungeon = DefaultState.startedFromDungeon; currentRating = FairCredit; }
/// <summary> /// The object factory for a particular data collection instance. /// </summary> public virtual void CreateObjectsFromData(CreditScores creditscores, System.Data.SqlClient.SqlDataReader data) { // Do nothing if we have nothing if (data == null) { return; } // Create a local variable for the new instance. CreditScore newobj = null; // Iterate through the data reader while (data.Read()) { // Create a new object instance newobj = System.Activator.CreateInstance(creditscores.ContainsType[0]) as CreditScore; // Let the instance set its own members newobj.SetMembers(ref data); // Add the new object to the collection instance creditscores.Add(newobj); } }
public void IntegralUpdate(CreditScore integral) { String stmtId = "CreditRecord_Update"; ExecuteUpdate(stmtId, integral); }
/// <summary> /// Persists the object. /// </summary> public virtual void Persist(CreditScore persistObject) { // Make a call to the overloaded method with a null transaction Persist(persistObject, null); }
public static void Initialize(CaseManagementContext context) { context.Database.EnsureCreated(); context.Database.Migrate(); if (!context.Statuses.Any()) { var statuses = new Status[] { new Status { Name = "Created" }, new Status { Name = "In Progress" }, new Status { Name = "All Outcomes Received" }, new Status { Name = "Declined" }, new Status { Name = "Submitted" }, new Status { Name = "Declined-Scoring" }, new Status { Name = "Declined-Affordability" }, new Status { Name = "Full Grant" }, }; foreach (Status s in statuses) { context.Statuses.Add(s); } context.SaveChanges(); } if (!context.CreditScores.Any()) { var CreditScores = new CreditScore[] { new CreditScore { Name = "Average" }, new CreditScore { Name = "Bad" }, new CreditScore { Name = "Excellent" }, new CreditScore { Name = "Good" }, }; foreach (CreditScore c in CreditScores) { context.CreditScores.Add(c); } context.SaveChanges(); } if (!context.IncomeTypes.Any()) { var IncomeTypes = new IncomeType[] { new IncomeType { Name = "Low" }, new IncomeType { Name = "Middle" }, new IncomeType { Name = "High" }, }; foreach (IncomeType i in IncomeTypes) { context.IncomeTypes.Add(i); } context.SaveChanges(); } if (!context.Positions.Any()) { var Position = new Position[] { new Position { Description = "Sales Admin" }, new Position { Description = "Sales Admin manager" }, }; foreach (Position i in Position) { context.Positions.Add(i); } context.SaveChanges(); } if (!context.Banks.Any()) { var Banks = new Bank[] { new Bank { Name = "ABSA" }, new Bank { Name = "Standard Bank SA" }, new Bank { Name = "FNB" }, new Bank { Name = "Nedbank" }, }; foreach (Bank b in Banks) { context.Banks.Add(b); } context.SaveChanges(); } if (!context.Applicants.Any()) { var Applicants = new Applicant[] { new Applicant { IdNumber = "9810015007086", FirstName = "Emmanuel", LastName = "Dube", Income = 340000, Credit = 400 }, new Applicant { IdNumber = "7812166007086", FirstName = "Busisiwe", LastName = "Mbatha", Income = 80000, Credit = 800 }, new Applicant { IdNumber = "8812105016089", FirstName = "Tumelo", LastName = "Malalane", Income = 340000, Credit = 699 }, new Applicant { IdNumber = "9712265016083", FirstName = "Sphamandla", LastName = "Motshoeni", Income = 50000, Credit = 210 }, new Applicant { IdNumber = "7410055098087", FirstName = "Nkosinathi", LastName = "Nkhomo", Income = 40000, Credit = 356 }, new Applicant { IdNumber = "7311166057086", FirstName = "Sabrina", LastName = "Anthony", Income = 35500, Credit = 609 }, new Applicant { IdNumber = "9702076006986", FirstName = "Chandre", LastName = "Kubie", Income = 23000, Credit = 899 }, new Applicant { IdNumber = "6801015800084", FirstName = "John", LastName = "Adams", Income = 2500, Credit = 320 }, new Applicant { IdNumber = "9706134800082", FirstName = "Amy", LastName = "Brammall", Income = 56000, Credit = 100 }, new Applicant { IdNumber = "9602075019086", FirstName = "Jessica", LastName = "Blue", Income = 230000, Credit = 564 }, new Applicant { IdNumber = "7509095000082", FirstName = "Dan", LastName = "Green", Income = 27000, Credit = 321 }, new Applicant { IdNumber = "7412066060089", FirstName = "Ben", LastName = "Cloete", Income = 29000, Credit = 900 }, new Applicant { IdNumber = "9201015007086", FirstName = "Billy", LastName = "Bulb", Income = 3400000, Credit = 679 }, new Applicant { IdNumber = "8812016007082", FirstName = "Ben", LastName = "Pukulski", Income = 800000, Credit = 546 }, new Applicant { IdNumber = "9703235016089", FirstName = "Bianca", LastName = "Gillies", Income = 40000, Credit = 985 }, new Applicant { IdNumber = "7702176007084", FirstName = "Iman", LastName = "Isaacs", Income = 12000, Credit = 590 }, new Applicant { IdNumber = "7410055098087", FirstName = "Michael", LastName = "Mabaso", Income = 60000, Credit = 505 }, new Applicant { IdNumber = "7311166057086", FirstName = "Sue", LastName = "Naidoo", Income = 43250, Credit = 134 }, new Applicant { IdNumber = "7402176006986", FirstName = "Jolene", LastName = "Grey", Income = 57000, Credit = 452 }, new Applicant { IdNumber = "6801015800084", FirstName = "Megan", LastName = "Van de Berg", Income = 150000, Credit = 546 }, new Applicant { IdNumber = "6911084800082", FirstName = "Madeleine", LastName = "Willemse", Income = 21000, Credit = 689 }, new Applicant { IdNumber = "9602075019086", FirstName = "Jess", LastName = "Green", Income = 230000, Credit = 987 }, new Applicant { IdNumber = "7509095000082", FirstName = "Nick", LastName = "Nxumalo", Income = 410000, Credit = 500 }, new Applicant { IdNumber = "7509066060087", FirstName = "Itumeleng", LastName = "Mehlape", Income = 30000, Credit = 900 } }; foreach (Applicant i in Applicants) { context.Applicants.Add(i); } context.SaveChanges(); } if (!context.Users.Any()) { var Users = new User[] { new User { Email = "*****@*****.**", FirstName = "Shaun", LastName = "Pollock", Password = "******" }, new User { Email = "*****@*****.**", FirstName = "Tristan", LastName = "Nickle", Password = "******" }, new User { Email = "*****@*****.**", FirstName = "Zed", LastName = "Springfield", Password = "******" }, new User { Email = "*****@*****.**", FirstName = "Megan", LastName = "Van de Berg", Password = "******" }, new User { Email = "*****@*****.**", FirstName = "Ben", LastName = "Mulligan", Password = "******" }, new User { Email = "*****@*****.**", FirstName = "John", LastName = "Pierce", Password = "******" }, new User { Email = "*****@*****.**", FirstName = "Jess", LastName = "Blue", Password = "******" } }; foreach (User i in Users) { context.Users.Add(i); } context.SaveChanges(); } if (!context.Cases.Any()) { Applicant[] applicants = new Applicant[3]; applicants[0] = context.Applicants .Include(applicant => applicant.CreditScore) .Include(applicant => applicant.IncomeType) .FirstOrDefault(applicant => applicant.IdNumber == "7410055098087"); applicants[1] = context.Applicants .Include(applicant => applicant.CreditScore) .Include(applicant => applicant.IncomeType) .FirstOrDefault(applicant => applicant.IdNumber == "9810015007086"); User tristan = context.Users.FirstOrDefault(u => u.FirstName == "Tristan"); var Cases = new Case[] { new Case { LoanAmount = 600000, Applicant = applicants[0], DateCreated = DateTime.Now, OfferToPurchaseDoc = true, Status = context.Statuses.FirstOrDefault(s => s.Name == "Created"), User = tristan }, new Case { LoanAmount = 900000, Applicant = applicants[1], DateCreated = DateTime.Now, OfferToPurchaseDoc = true, Status = context.Statuses.FirstOrDefault(s => s.Name == "In Progress"), User = tristan } }; foreach (Case i in Cases) { context.Cases.Add(i); } context.SaveChanges(); } if (!context.Submissions.Any()) { Applicant applicantInprogress = context.Applicants.FirstOrDefault(a => a.IdNumber == "9810015007086"); Bank bank = context.Banks.FirstOrDefault(b => b.Name == "ABSA"); Case caseApplicant = context.Cases.FirstOrDefault(c => c.Applicant == applicantInprogress); Status startStatus = context.Statuses.FirstOrDefault(s => s.Name == "Submitted"); var Submissions = new Submission[] { new Submission { Bank = bank, BankResponseDateTime = DateTime.Now, Case = caseApplicant, BankResponseDoc = true, DateSubmitted = DateTime.Now, Status = startStatus } }; foreach (Submission i in Submissions) { context.Submissions.Add(i); } context.SaveChanges(); } }
private void LVScores_SelectionChanged(object sender, SelectionChangedEventArgs e) => _selectedScore = LVScores.SelectedIndex >= 0 ? (CreditScore)LVScores.SelectedItem : new CreditScore();
/// <summary> /// Persists the object. /// </summary> public virtual void Persist(CreditScore persistObject, SqlTransaction sqlTrans) { // create local variable array for the sql parameters SqlParameterHash sqlparams = null; // Create a local variable for the connection SqlConnection cnn = null; // Use the parameter overload or create a new instance if (sqlTrans == null) { cnn = new SqlConnection(CreditScore.GetConnectionString()); } try { // discover the parameters if (persistObject.Persisted) { sqlparams = SqlHelperParameterCache.GetSpParameterSet(CreditScore.GetConnectionString(), "gsp_UpdateCreditScore"); } else { sqlparams = SqlHelperParameterCache.GetSpParameterSet(CreditScore.GetConnectionString(), "gsp_CreateCreditScore"); } // Store the parameter for the CreditReportIdentifier attribute. if (!persistObject.CreditReportIdentifierIsNull) { sqlparams["@creditReportIdentifier"].Value = persistObject.CreditReportIdentifier; } // Store the parameter for the CreditScoreDate attribute. if (!persistObject.CreditScoreDateIsNull) { sqlparams["@creditScoreDate"].Value = persistObject.CreditScoreDate; } // Store the parameter for the CreditScoreModelNameTypeOtherDescription attribute. if (!persistObject.CreditScoreModelNameTypeOtherDescriptionIsNull) { sqlparams["@creditScoreModelNameTypeOtherDescription"].Value = persistObject.CreditScoreModelNameTypeOtherDescription; } // Store the parameter for the CreditScoreValue attribute. if (!persistObject.CreditScoreValueIsNull) { sqlparams["@creditScoreValue"].Value = persistObject.CreditScoreValue; } // Store the parameter for the BorrowerId attribute. sqlparams["@borrowerId"].Value = persistObject.BorrowerId; // Store the parameter for the CreditRepositorySourceType attribute. if (!persistObject.CreditRepositorySourceTypeIsNull) { sqlparams["@creditRepositorySourceType"].Value = persistObject.CreditRepositorySourceType; } // Store the parameter for the CreditScoreExclusionType attribute. if (!persistObject.CreditScoreExclusionTypeIsNull) { sqlparams["@creditScoreExclusionType"].Value = persistObject.CreditScoreExclusionType; } // Store the parameter for the CreditScoreModelNameType attribute. if (!persistObject.CreditScoreModelNameTypeIsNull) { sqlparams["@creditScoreModelNameType"].Value = persistObject.CreditScoreModelNameType; } // Store the parameter for the CreditScoreID attribute. if (!persistObject.Persisted) { // store the create only (historical fixed) values } else { // store the update only (historical changeable) values // Store the parameter for the CreditScoreID attribute. sqlparams["@creditScoreID"].Value = persistObject.CreditScoreID; } if (sqlTrans == null) { // Process using the isolated connection using (cnn) { // open the connection cnn.Open(); if (!persistObject.Persisted) { persistObject._creditscoreid = Convert.ToInt64(SqlHelper.ExecuteScalar(cnn, CommandType.StoredProcedure, "gsp_CreateCreditScore", sqlparams)); } else { SqlHelper.ExecuteNonQuery(cnn, CommandType.StoredProcedure, "gsp_UpdateCreditScore", sqlparams); } // close the connection after usage cnn.Close(); } // nullify the connection var cnn = null; } else { // Process using the shared transaction if (!persistObject.Persisted) { persistObject._creditscoreid = Convert.ToInt64(SqlHelper.ExecuteScalar(sqlTrans, CommandType.StoredProcedure, "gsp_CreateCreditScore", sqlparams)); } else { SqlHelper.ExecuteNonQuery(sqlTrans, CommandType.StoredProcedure, "gsp_UpdateCreditScore", sqlparams); } } } catch (SqlException sqlex) { throw sqlex; } }
public IResult Delete(CreditScore entity) { _creditScoreDal.Delete(entity); return(new SuccessResult(Messages.CreditScoreDeleted)); }
public IDataResult <CreditScore> CalculateCreditScore(CreditScore creditScore) { creditScore.MinCreditScore = new Random().Next(0, 1901); return(new SuccessDataResult <CreditScore>(creditScore)); }
/// <summary>Modifies a credit score in the database.</summary> /// <param name="oldScore">Original score</param> /// <param name="newScore">Modified score</param> /// <returns>True if successful</returns> public static Task <bool> ModifyCreditScore(CreditScore oldScore, CreditScore newScore) => DatabaseInteraction.ModifyCreditScore(oldScore, newScore);
/// <summary>Deletes a credit score from the database</summary> /// <param name="deleteScore">Score to be deleted</param> /// <returns>True if successful</returns> public static Task <bool> DeleteCreditScore(CreditScore deleteScore) => DatabaseInteraction.DeleteCreditScore(deleteScore);
/// <summary>Adds a new credit score to the database.</summary> /// <param name="newScore">Score to be added</param> /// <returns>True if successful</returns> public static Task <bool> AddCreditScore(CreditScore newScore) => DatabaseInteraction.AddCreditScore(newScore);
public IResult Add(CreditScore creditScore) { _creditScoreDal.Add(creditScore); return(new SuccessResult(Messages.CreditScoreAdded)); }
public ActionResult RequestLoan(Loans_RequestLoan_VM Model) { if (!UserAccount.IsLoggedIn(this)) { return(RedirectToAction("SendToLogin", "Account", new { Something = "" })); } if (!ModelState.IsValid) { return(View(Model)); } int UserID = (UserAccount.ActiveUser != null) ? UserAccount.ActiveUser.ID : 1027 /*For Debug*/; var Loan = new LoanRequest().New(); Loan.UserID = UserID; Loan.SocialSecurity = Model.SocialSecurity; Loan.Income = Model.Income; Loan.Employer = Model.Employer; Loan.JobTitle = Model.JobTitle; Loan.EmploymentType = Model.EmploymentType; Loan.Amount = Model.Amount; Loan.Terms = Model.Terms; Loan.DownPayment = Model.DownPayment; Loan.LoanType = Model.LoanType; Loan.Status = "Pending"; if (!Loan.Save()) { TempData["AlertTag"] = "danger"; TempData["AlertLabel"] = "Error: "; TempData["AlertMessage"] = "Loan request could not be saved."; return(View(Model)); } var Score = CreditScore.GetByUserID(UserID).TransUnion; //JDR: Call Api to calclate Result // ... Code ... var LoanProperties = new { Terms = Model.Terms, Amount = Model.Amount, Income = Model.Income, DownPayment = Model.DownPayment, CreditScore = Score, APR = LoanResult.CalculateAPR((int)Score, (int)Model.Terms), }; var Result = new LoanResult().New(); Result.RequestID = Loan.ID; Result.Amount = Model.Amount; Result.Term = Model.Terms; Result.ResolutionDate = DateTime.Now; Result.CreditScore = LoanProperties.CreditScore; Result.APR = LoanProperties.APR; Result.MonthlyPayment = LoanResult.CalculateMonthlyPayment(LoanProperties); Result.Decision = "Pending"; Result.Comments = "Loan has been recived and is pending review."; double IncomeYrTotal = (double)Model.Income; double DebtMonthTotal = (double)Result.MonthlyPayment; var UserLoans = LoanRequest.GetLoanRequestsByUserID(UserID); //JDR: Factor in other loans to debt equation foreach (LoanRequest LoanElement in UserLoans) { //if (!LoanElement.Active()) continue; if (LoanElement.Status.Trim() != "Approved") { continue; } LoanResult ResultElement = LoanElement.GetLoanResults(); if (ResultElement == null) { continue; } DebtMonthTotal += (double)ResultElement.MonthlyPayment; } var DebtToIncome = LoanResult.CalculateDebtToIncomePercent(IncomeYrTotal, DebtMonthTotal); //JDR: Save Loan approved/denied result if (LoanResult.IsLoanApproved(DebtToIncome, Model.LoanType)) { Loan.Status = "Approved"; Result.Decision = "Approved"; Result.Comments = "Loan has been approved for a total of " + Result.Amount.ToString("$###,###.##") + "."; } else { Loan.Status = "Denied"; Result.Decision = "Denied"; Result.Comments = "Loan has beed denied do to debt to income ratio."; Result.APR = 0.0; Result.MonthlyPayment = 0.0; } Loan.Save(); if (!Result.Save()) { TempData["AlertTag"] = "danger"; TempData["AlertLabel"] = "Error: "; TempData["AlertMessage"] = "Loan request cound not save/compute result of request."; return(RedirectToAction("Dashboard", "Account")); } /*//DEBUG * TempData["AlertMessage"] = ""; * TempData["AlertMessage"] += DEBUG.ObjectToString(Loan) + "<hr>"; * TempData["AlertMessage"] += DEBUG.ObjectToString(Result) + "<hr>"; * TempData["AlertMessage"] += DEBUG.ObjectToString(LoanProperties) + "<hr>"; * TempData["AlertMessage"] += "Result.MonthlyPayment = " + Result.MonthlyPayment + "<hr>"; * TempData["AlertMessage"] += "IncomeYrTotal = "+ IncomeYrTotal + "<hr>"; * TempData["AlertMessage"] += "DebtMonthTotal = " + DebtMonthTotal + "<hr>"; * TempData["AlertMessage"] += "DebtToIncome = " + DebtToIncome + "<hr>"; * return View(); * //*/ TempData["AlertTag"] = "success"; TempData["AlertLabel"] = "Success!: "; TempData["AlertMessage"] = "Loan request has been submited."; return(RedirectToAction("Dashboard", "Account")); }
public IResult Update(CreditScore creditScore) { _creditScoreDal.Update(creditScore); return(new SuccessResult(Messages.CreditScoreUpdated)); }
/// <summary> /// Returns true if CreditProfile instances are equal /// </summary> /// <param name="other">Instance of CreditProfile to be compared</param> /// <returns>Boolean</returns> public bool Equals(CreditProfile other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( CreditProfileDate == other.CreditProfileDate || CreditProfileDate != null && CreditProfileDate.Equals(other.CreditProfileDate) ) && ( CreditRiskRating == other.CreditRiskRating || CreditRiskRating != null && CreditRiskRating.Equals(other.CreditRiskRating) ) && ( CreditScore == other.CreditScore || CreditScore != null && CreditScore.Equals(other.CreditScore) ) && ( ValidFor == other.ValidFor || ValidFor != null && ValidFor.Equals(other.ValidFor) ) && ( TagCreditScoring == other.TagCreditScoring || TagCreditScoring != null && TagCreditScoring.Equals(other.TagCreditScoring) ) && ( TagCreditLimit == other.TagCreditLimit || TagCreditLimit != null && TagCreditLimit.Equals(other.TagCreditLimit) ) && ( TagCreditThreshold == other.TagCreditThreshold || TagCreditThreshold != null && TagCreditThreshold.Equals(other.TagCreditThreshold) ) && ( TagCreditOnHold == other.TagCreditOnHold || TagCreditOnHold != null && TagCreditOnHold.Equals(other.TagCreditOnHold) ) && ( TagContractDailyCreditLimit == other.TagContractDailyCreditLimit || TagContractDailyCreditLimit != null && TagContractDailyCreditLimit.Equals(other.TagContractDailyCreditLimit) ) && ( TagContractPeriodicCreditLimit == other.TagContractPeriodicCreditLimit || TagContractPeriodicCreditLimit != null && TagContractPeriodicCreditLimit.Equals(other.TagContractPeriodicCreditLimit) )); }