示例#1
0
 public PrimaryLoan GetRandomNonDetailedLoan()
 {
     using (MintosEntities mintosEntities = new MintosEntities())
     {
         return(mintosEntities.PrimaryLoans.Where(x => x.Detail_ID == null).OrderBy(r => Guid.NewGuid()).FirstOrDefault());
     }
 }
示例#2
0
 public PrimaryLoan GetFirstNonDetailedLoan()
 {
     using (MintosEntities mintosEntities = new MintosEntities())
     {
         return(mintosEntities.PrimaryLoans.Where(x => x.Detail_ID == null).FirstOrDefault());
     }
 }
示例#3
0
 public void UpdateLoanDetailsID(int detailsID, Data.EF.PrimaryLoan primaryLoan)
 {
     using (MintosEntities mintosEntities = new MintosEntities())
     {
         mintosEntities.PrimaryLoans.Where(x => x.ID == primaryLoan.ID).SingleOrDefault().Detail_ID = detailsID;
         mintosEntities.SaveChanges();
     }
 }
示例#4
0
 public int AddDetails(Data.EF.LoanDetail loanDetail)
 {
     using (MintosEntities mintosEntities = new MintosEntities())
     {
         loanDetail = mintosEntities.LoanDetails.Add(loanDetail);
         mintosEntities.SaveChanges();
         return(loanDetail.DetailsID);
     }
 }
示例#5
0
        public void UpdateOrAddPrimaryLoans(List <PrimaryLoan> primaryLoansList)
        {
            using (MintosEntities mintosEntities = new MintosEntities())
            {
                foreach (var loanItem in primaryLoansList)
                {
                    if (mintosEntities.PrimaryLoans.Any(x => x.ID == loanItem.ID))
                    {
                        Console.WriteLine("Updating " + loanItem.ID);
                        var loanInDB = mintosEntities.PrimaryLoans.Where(x => x.ID == loanItem.ID).Single();
                        loanInDB.Country             = loanItem.Country;
                        loanInDB.Issue_Date          = loanItem.Issue_Date;
                        loanInDB.Closing_Date        = loanItem.Closing_Date;
                        loanInDB.Loan_Type           = loanItem.Loan_Type;
                        loanInDB.Amortization_Method = loanItem.Amortization_Method;
                        loanInDB.Loan_Originator     = loanItem.Loan_Originator;
                        loanInDB.Loan_Amount         = loanItem.Loan_Amount;
                        loanInDB.Remaining_Principal = loanItem.Remaining_Principal;
                        loanInDB.LTV               = loanItem.LTV;
                        loanInDB.Interest_Rate     = loanItem.Interest_Rate;
                        loanInDB.Term              = loanItem.Term;
                        loanInDB.Payments_Received = loanItem.Payments_Received;
                        loanInDB.Status            = loanItem.Status;
                        loanInDB.Amount_Available_for_Investment = loanItem.Amount_Available_for_Investment;
                        loanInDB.Buyback_Guarantee = loanItem.Buyback_Guarantee;
                        loanInDB.My_Investments    = loanItem.My_Investments;
                        loanInDB.Currency          = loanItem.Currency;
                        loanInDB.Borrower_APR      = loanItem.Borrower_APR;
                    }
                    else
                    {
                        //add
                        Console.WriteLine("Adding " + loanItem.ID);

                        mintosEntities.PrimaryLoans.Add(loanItem);
                    }
                }
                Console.WriteLine("Inserting/Updating Database");
                mintosEntities.SaveChanges();
            }
        }
示例#6
0
        public LoanDetail GetDetails(HtmlNodeCollection tableRowDescriptions, HtmlNodeCollection tableRowValues)
        {
            LoanDetail loanDetail = new LoanDetail();

            for (int i = 0; i < tableRowDescriptions.Count; i++)
            {
                switch (tableRowDescriptions[i].InnerText.Trim())
                {
                case "Previous Loans":
                    loanDetail.PreviousLoans = int.Parse(tableRowValues[i].InnerText.Trim());
                    break;

                case "Loan Purpose":
                    loanDetail.Loan_Purpose = tableRowValues[i].InnerText.Trim();
                    break;

                case "Borrower":
                    loanDetail.Borrower = tableRowValues[i].InnerText.Trim();

                    if (tableRowValues[i].InnerText.Trim().Contains("Male"))
                    {
                        loanDetail.Gender = "Male";
                    }

                    else if (tableRowValues[i].InnerText.Trim().Contains("Female"))
                    {
                        loanDetail.Gender = "Female";
                    }

                    System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"\d+");

                    if (regex.IsMatch(tableRowValues[i].InnerText.Trim()))
                    {
                        loanDetail.Age = int.Parse(regex.Match(tableRowValues[i].InnerText.Trim()).ToString());
                    }

                    break;

                case "Business Sector":
                    loanDetail.Business_Sector = tableRowValues[i].InnerText.Trim();
                    break;

                case "Description":
                    loanDetail.Description = tableRowValues[i].InnerText.Trim();
                    break;

                case "Country":
                    loanDetail.Country = tableRowValues[i].InnerText.Trim();
                    break;

                case "Risk category":
                    loanDetail.Risk_category = tableRowValues[i].InnerText.Trim();
                    break;

                case "Estimated annual default rate":
                    loanDetail.Estimated_annual_default_rate = float.Parse(tableRowValues[i].InnerText.Trim());
                    break;

                case "Collateral":
                    loanDetail.Collateral = tableRowValues[i].InnerText.Trim();
                    break;

                case "Valuation":
                    loanDetail.Valuation = tableRowValues[i].InnerText.Trim();
                    break;

                case "Personal guarantee":
                    loanDetail.Personal_guarantee = tableRowValues[i].InnerText.Trim();
                    break;

                case "Registered":
                    loanDetail.Registered = DateTime.ParseExact(tableRowValues[i].InnerText.Trim(), "dd.MM.yyyy", CultureInfo.InvariantCulture);
                    break;

                case "Invoice Transaction":
                    loanDetail.Invoice_Transaction = tableRowValues[i].InnerText.Trim();
                    break;

                case "Invoice Recourse":
                    loanDetail.Invoice_Recourse = tableRowValues[i].InnerText.Trim();
                    break;

                case "Real Estate Type":
                    loanDetail.Real_Estate_Type = tableRowValues[i].InnerText.Trim();
                    break;

                case "Size":
                    loanDetail.Size = tableRowValues[i].InnerText.Trim();
                    break;

                case "VAT Country":
                    loanDetail.VAT_Country = tableRowValues[i].InnerText.Trim();
                    break;

                case "Liability":
                    loanDetail.Liability = tableRowValues[i].InnerText.Trim();
                    break;

                case "Pledge Type":
                    loanDetail.Pledge_Type = tableRowValues[i].InnerText.Trim();
                    break;

                case "Occupation":
                    loanDetail.Occupation = tableRowValues[i].InnerText.Trim();
                    break;

                case "Dependents":
                    loanDetail.Dependents = tableRowValues[i].InnerText.Trim();
                    break;

                case "Model":
                    loanDetail.Model = tableRowValues[i].InnerText.Trim();
                    break;

                case "Vehicle type":
                    loanDetail.Vehicle_type = tableRowValues[i].InnerText.Trim();
                    break;

                case "Engine":
                    loanDetail.Engine = tableRowValues[i].InnerText.Trim();
                    break;

                case "Manufacturing Year":
                    loanDetail.Manufacturing_Year = tableRowValues[i].InnerText.Trim();
                    break;

                case "Previous Loans with the Same Loan Originator":
                    loanDetail.Previous_Loans_with_the_Same_Loan_Originator = int.Parse(tableRowValues[i].InnerText.Trim());
                    break;

                case "Appraiser":
                    break;

                default:
                    string descriptorText = tableRowDescriptions[i].InnerText;
                    Console.WriteLine(descriptorText + "\n" + tableRowValues[i].InnerText + "\n\n");
                    MintosEntities mintosEntities = new MintosEntities();
                    if (!mintosEntities.InformationToAdds.Any(x => x.Description == descriptorText))
                    {
                        Data.EF.InformationToAdd informationToAdd = new InformationToAdd();
                        informationToAdd.Description = descriptorText;
                        mintosEntities.InformationToAdds.Add(informationToAdd);
                        mintosEntities.SaveChanges();
                    }
                    break;
                }
            }

            return(loanDetail);
        }