Пример #1
0
 public UnitOfWork(FELFELContext context)
 {
     _context     = context;
     Batches      = new BatchRepository(_context);
     Products     = new ProductRepository(_context);
     StockChanges = new BatchStockChangeRepository(_context);
 }
Пример #2
0
        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();
            }
        }
Пример #3
0
 public ProductRepository(FELFELContext context) : base(context)
 {
 }
Пример #4
0
 public BatchRepository(FELFELContext context) : base(context)
 {
 }