示例#1
0
        public Startup(IHostingEnvironment env)
        {
            using (var client = new InventoryContext())
            {
                client.Database.EnsureCreated();
            }

            using (var client = new UserContext())
            {
                client.Database.EnsureCreated();
            }

            using (var client = new PurchaseOrderContext())
            {
                client.Database.EnsureCreated();
            }
        }
示例#2
0
 public ReportingController(PurchaseOrderContext context)
 {
     _context = context;
 }
        private static async Task Seed(PurchaseOrderContext context)
        {
            if (await context.PurchaseOrders.AnyAsync())
            {
                return;
            }

            var date      = DateTime.UtcNow.Date;
            var finalDate = date.AddDays(30);

            context.Products.Add(new Product("Sapato", 10.0m));
            context.Products.Add(new Product("Boné", 15.0m));
            context.Products.Add(new Product("Chinelo", 18.0m));
            context.Products.Add(new Product("Calça", 25.0m));
            context.Products.Add(new Product("Tenis", 35.0m));

            await context.SaveChangesAsync();

            var productRandom       = new Random();
            var productAmountRandom = new Random();

            for (var day = date.Date; day.Date <= finalDate.Date; day = day.AddDays(1))
            {
                var order = new PurchaseOrder()
                {
                    Date     = day,
                    Customer = new Customer($"Customer {day}")
                };

                var productId = productRandom.Next(1, 5);
                var quant     = productAmountRandom.Next(1, 4);

                order.ProductOrders.Add(new PurchaseOrderProduct()
                {
                    Quantity  = quant,
                    Product   = context.Products.First(w => w.Id == productId),
                    UnitValue = context.Products.First(w => w.Id == productId).Value
                });

                productId = productRandom.Next(1, 5);
                quant     = productAmountRandom.Next(1, 4);

                order.ProductOrders.Add(new PurchaseOrderProduct()
                {
                    Quantity  = quant,
                    Product   = context.Products.First(w => w.Id == productId),
                    UnitValue = context.Products.First(w => w.Id == productId).Value
                });

                productId = productRandom.Next(1, 5);
                quant     = productAmountRandom.Next(1, 4);

                order.ProductOrders.Add(new PurchaseOrderProduct()
                {
                    Quantity  = quant,
                    Product   = context.Products.First(w => w.Id == productId),
                    UnitValue = context.Products.First(w => w.Id == productId).Value
                });

                productId = productRandom.Next(1, 5);
                quant     = productAmountRandom.Next(1, 4);

                order.ProductOrders.Add(new PurchaseOrderProduct()
                {
                    Quantity  = quant,
                    Product   = context.Products.First(w => w.Id == productId),
                    UnitValue = context.Products.First(w => w.Id == productId).Value
                });

                order.TotalValue = order.ProductOrders.Sum(s => s.UnitValue * s.Quantity);

                context.PurchaseOrders.Add(order);
            }

            await context.SaveChangesAsync();
        }
示例#4
0
 public ProductsController(PurchaseOrderContext context)
 {
     _context = context;
 }
示例#5
0
 public MigrationHostedService(PurchaseOrderContext purchaseOrderContext)
 {
     _purchaseOrderContext = purchaseOrderContext;
 }
 public PurchaseOrderRepository(DbContext context) : base(context)
 {
     _dbContext = (_dbContext ?? (PurchaseOrderContext)context);
 }
 public PurchaseOrderShippingsController(PurchaseOrderContext context)
 {
     _context = context;
 }
示例#8
0
 public VendorsController(PurchaseOrderContext context)
 {
     _context = context;
 }
示例#9
0
 public UserService(IOptions <AppSettings> appSettings, PurchaseOrderContext context)
 {
     _appSettings = appSettings.Value;
     _context     = context;
 }
 public PurchaseOrderController(PurchaseOrderContext context, PurchaseOrderContextnew contextnew)
 {
     _context    = context;
     _contextnew = contextnew;
 }
 public SupplierController(PurchaseOrderContext context)
 {
     _context = context;
 }
 public ClientsController(PurchaseOrderContext context)
 {
     _context = context;
 }