Exemplo n.º 1
0
        public void CreateShipment(Shipment shipment)
        {
            if (_dbContext.Shipments.Any(s => s.ShipmentID == shipment.ShipmentID))
            {
                return;
            }

            _dbContext.Shipments.Add(shipment);

            _dbContext.SaveChanges();
        }
Exemplo n.º 2
0
        public static void AddMockData(ShipmentContext context)
        {
            if (context.Shipments.Any())
            {
                return;   // DB has been seeded.
            }

            var shipment = new Shipment()
            {
                Orders       = GenerateOrders(),
                DeliveryDate = DateTime.Now.AddDays(20),
                Departure    = "Abisko",
                Destination  = "Greenland",
                ShipmentDate = DateTime.Now,
            };

            context.Shipments.Add(shipment);

            var shipment2 = new Shipment()
            {
                Orders       = GenerateOrders(),
                DeliveryDate = DateTime.Now.AddDays(20),
                Departure    = "Bremen",
                Destination  = "New York",
                ShipmentDate = DateTime.Now,
            };

            context.Shipments.Add(shipment2);

            var shipment3 = new Shipment()
            {
                Orders       = GenerateOrders(),
                DeliveryDate = DateTime.Now.AddDays(5),
                Departure    = "Copenhagen",
                Destination  = "London",
                ShipmentDate = DateTime.Now,
            };

            context.Shipments.Add(shipment3);

            context.SaveChanges();
        }