示例#1
0
        public static void LoadPipelines()
        {
            var db = new Entities();
            var path = HostingEnvironment.MapPath(@"~/pipeline.csv");
            using (var pipeline = new StreamReader(path))
            {
                pipeline.ReadLine(); //skip header
                while (pipeline.Peek() >= 0)
                {
                    var line = pipeline.ReadLine().Split(',');
                    var purpose = line[5];
                    db.Pipelines.Add(new Pipeline
                    {
                        LoanOfficerKey = line[0],
                        LoanNumber = line[1],
                        BorrowerFirstName = line[2],
                        BorrowerLastName = line[3],
                        Amount = decimal.Parse(line[4]),
                        Purpose = db.Purposes.First(x=>x.Name == purpose),
                        Originated = DateTime.Parse(line[6]),
                        SubmittedToUW = DateTime.Parse(line[7]),
                        Funded = DateTime.Parse(line[8])
                    });
                }
            }

            db.SaveChanges();
        }
示例#2
0
        public static void LoadOfficers()
        {
            var db = new Entities();
            var path = HostingEnvironment.MapPath(@"~/loan-officers.csv");
            using (var officers = new StreamReader(path))
            {
                officers.ReadLine(); //skip header
                while (officers.Peek() >= 0)
                {
                    var line = officers.ReadLine().Split(',');
                    db.LoanOfficers.Add(new LoanOfficer
                    {
                        Key = line[0],
                        FirstName = line[1],
                        LastName = line[2],
                        Email = line[3],
                        Title = line[4],
                        City = line[5],
                        State = line[6]
                    });
                }
            }

            db.SaveChanges();
        }
示例#3
0
 //Recreates tables, should I need to clear them.
 public static void Go()
 {
     var db = new Entities();
     if (!db.LoanOfficers.Any())
         LoadOfficers();
     if (!db.Pipelines.Any())
         LoadPipelines();
 }
示例#4
0
 public JsonResult Pipeline(string key)
 {
     var db = new Entities();
     var pipeline = db.Pipelines.Where(x => x.LoanOfficerKey == key)
         .Select(x => new
         {
             x.LoanNumber,
             x.Amount,
             x.BorrowerFirstName,
             x.BorrowerLastName,
             Purpose = x.Purpose.Name,
         })
         .OrderBy(x => x.LoanNumber);
     return Json(pipeline, JsonRequestBehavior.AllowGet);
 }
示例#5
0
 public JsonResult Totals(string key)
 {
     var db = new Entities();
     var data = db.Database.SqlQuery<PipelineResult>("PipelineData {0}", key).Single();
     return Json(new object[] { data }, JsonRequestBehavior.AllowGet);
 }
示例#6
0
 public JsonResult Officers()
 {
     var db = new Entities();
     return Json(db.LoanOfficers.ToList(), JsonRequestBehavior.AllowGet);
 }