Ejemplo n.º 1
0
 private void AddNewListOfPurchases(List <Purchase> listOfPurchases)
 {
     using (var context = new CPAcontext())
     {
         foreach (var purchase in listOfPurchases)
         {
             context.Purchase.Add(purchase);
         }
         context.SaveChanges();
     }
 }
Ejemplo n.º 2
0
        private void AddTenCustomers()
        {
            var customer = new Customer()
            {
                FirstName = "Anna",
                LastName  = "Toresson",
                Email     = "*****@*****.**",
            };
            var customer1 = new Customer()
            {
                FirstName = "Anderas",
                LastName  = "Hellström",
                Email     = "*****@*****.**",
            };
            var customer2 = new Customer()
            {
                FirstName = "Joakim",
                LastName  = "Bring",
                Email     = "*****@*****.**",
            };
            var customer3 = new Customer()
            {
                FirstName = "Jon",
                LastName  = "Jönsson",
                Email     = "*****@*****.**",
            };
            var customer4 = new Customer()
            {
                FirstName = "Petra",
                LastName  = "Svensson",
                Email     = "*****@*****.**",
            };
            var customer5 = new Customer()
            {
                FirstName = "Roland",
                LastName  = "Andersson",
                Email     = "*****@*****.**",
            };
            var customer6 = new Customer()
            {
                FirstName = "Dennis",
                LastName  = "Randevall",
                Email     = "*****@*****.**",
            };
            var customer7 = new Customer()
            {
                FirstName = "Sofia",
                LastName  = "Svensson",
                Email     = "*****@*****.**",
            };
            var customer8 = new Customer()
            {
                FirstName = "Karl",
                LastName  = "Karlsson",
                Email     = "*****@*****.**",
            };
            var customer9 = new Customer()
            {
                FirstName = "Sara",
                LastName  = "Persson",
                Email     = "*****@*****.**",
            };

            using (var context = new CPAcontext())
            {
                context.Customers.AddRange(customer, customer1, customer2, customer3, customer4, customer5, customer6, customer7, customer8, customer9);
                context.SaveChanges();
            }
        }