Esempio n. 1
0
        private static void CreateProductionUnits(CapacityPlan cp, int count)
        {
            Console.WriteLine("Inserting ProductionUnits...");
            for (var i = 0; i < count; i++)
            {
                var pu = new ProductionUnit()
                {
                    CapacityPlan = cp,
                    Name         = $"Production Unit {i + 1}"
                };
                cp.ProductionUnits.Add(pu);

                CreateProductionUnitModes(pu, 2);
            }

            Console.WriteLine("Inserted ProductionUnits");
        }
Esempio n. 2
0
        private static void DeleteCapacityPlan(int id)
        {
            var sw = Stopwatch.StartNew();

            Console.WriteLine("Deleting Capacity Plan... ");

            using (var context = new AppDbContext())
            {
                // context.Database.Log = Console.Write;

                var cp = new CapacityPlan()
                {
                    Id = id
                };
                context.CapacityPlans.Attach(cp);
                context.CapacityPlans.Remove(cp);

                var changes = context.SaveChanges();
                Console.WriteLine($"Removing {id}. Removed {changes} rows. Time Taken: {sw.ElapsedMilliseconds} milliseconds");
            }
        }
Esempio n. 3
0
        private static int AddCapacityPlan()
        {
            var sw = Stopwatch.StartNew();

            Console.WriteLine("Inserting Capacity Plan... ");

            using (var context = new AppDbContext())
            {
                var cp = new CapacityPlan
                {
                    Description = "cp1",
                    CreateDate  = DateTime.Now
                };

                CreateProductionUnits(cp, 48);

                context.CapacityPlans.Add(cp);
                context.SaveChanges();

                Console.WriteLine($"Inserted Capacity Plan. Added new id {cp.Id}, Time Taken: {(sw.ElapsedMilliseconds / 1000)} seconds");

                return(cp.Id);
            }
        }