private void CreateFakeInvestmentContext()
        {
            if (this.db == null)
            {
                this.db = new InvestmentContext();
            }

            // clear out any old data first
            ClearFakeInvestmentData();

            // add a set of investments
            db.Investments.Add(new Investment {
                Id = 1, Name = "Investment A", UserId = 1
            });
            db.Investments.Add(new Investment {
                Id = 2, Name = "Investment B", UserId = 1
            });
            db.Investments.Add(new Investment {
                Id = 3, Name = "Investment A", UserId = 2
            });
            db.Investments.Add(new Investment {
                Id = 4, Name = "Investment C", UserId = 2
            });
            db.Investments.Add(new Investment {
                Id = 5, Name = "Investment D", UserId = 3
            });

            // add a set of investmentdetails
            db.InvestmentDetails.Add(new InvestmentDetail {
                Id = 1, InvestmentId = 1, Shares = 5, CostBasisPerShare = 14, CurrentPrice = 55, PurchaseDate = DateTime.UtcNow
            });
            db.InvestmentDetails.Add(new InvestmentDetail {
                Id = 2, InvestmentId = 2, Shares = 10, CostBasisPerShare = 3.50, CurrentPrice = 13.50, PurchaseDate = DateTime.UtcNow
            });
            db.InvestmentDetails.Add(new InvestmentDetail {
                Id = 3, InvestmentId = 3, Shares = 20, CostBasisPerShare = 12.75, CurrentPrice = 9.70, PurchaseDate = DateTime.UtcNow
            });
            db.InvestmentDetails.Add(new InvestmentDetail {
                Id = 4, InvestmentId = 4, Shares = 25, CostBasisPerShare = 33, CurrentPrice = 38, PurchaseDate = DateTime.UtcNow
            });
            db.InvestmentDetails.Add(new InvestmentDetail {
                Id = 5, InvestmentId = 5, Shares = 40, CostBasisPerShare = 45.90, CurrentPrice = 80.45, PurchaseDate = new DateTime(2015, 12, 31, 5, 10, 20, DateTimeKind.Utc)
            });

            db.SaveChanges();
        }
 public InvestmentController()
 {
     this.db = new InvestmentContext();
     PopulateFakeInvestmentData();
 }
 public InvestmentController(IInvestmentContext context)
 {
     this.db = context;
 }
Beispiel #4
0
 public CapitalService(IInvestmentContext context)
 {
     _context = context;
 }