public UnitOfWork(FELFELContext context) { _context = context; Batches = new BatchRepository(_context); Products = new ProductRepository(_context); StockChanges = new BatchStockChangeRepository(_context); }
public static void EnsurePopulated(IApplicationBuilder app) { FELFELContext context = app.ApplicationServices .GetRequiredService <FELFELContext>(); context.Database.Migrate(); if (!context.Batches.Any()) { context.Batches.AddRange( new Batch { ProductType = new Product { Name = "Spaghetti" }, Expiration = new DateTime(2018, 8, 1), Arrival = new DateTime(2018, 6, 1), OriginalUnitAmount = 400, RemainingUnits = 200, History = new HashSet <BatchStockChange>() }, new Batch { ProductType = new Product { Name = "Spaghetti" }, Expiration = new DateTime(2018, 8, 1), Arrival = new DateTime(2018, 6, 1), OriginalUnitAmount = 400, RemainingUnits = 200, History = new HashSet <BatchStockChange>() }, new Batch { ProductType = new Product { Name = "Oats" }, Expiration = new DateTime(2018, 8, 1), Arrival = new DateTime(2018, 6, 1), OriginalUnitAmount = 400, RemainingUnits = 200, History = new HashSet <BatchStockChange>() }, new Batch { ProductType = new Product { Name = "Tamatoes" }, Expiration = new DateTime(2018, 8, 1), Arrival = new DateTime(2018, 6, 1), OriginalUnitAmount = 400, RemainingUnits = 200, History = new HashSet <BatchStockChange>() }); context.SaveChanges(); } }
public ProductRepository(FELFELContext context) : base(context) { }
public BatchRepository(FELFELContext context) : base(context) { }