public Customer Add(Customer entity) { var newCustomer = db.Customers.Add(entity).Entity; db.SaveChanges(); return(newCustomer); }
Customer IRepository <Customer> .Add(Customer entity) { var newCustomer = db.Customers.Add(entity).Entity; db.SaveChanges(); return(newCustomer); }
// This method will create and seed the database. public void Initialize(CustomerApiContext context) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); // Look for any Products if (context.Customers.Any()) { return; // DB has been seeded } List <Customer> customers = new List <Customer> { new Customer { CustomerId = 1, FullName = "Peder Hansen", Email = "*****@*****.**", Phone = "12345678", CreditStanding = 500, BillingAddress = "Gade 1B, Tyskland", ShippingAddress = "Gade 1B, Tyskland" }, new Customer { CustomerId = 2, FullName = "Fredrik Hansen", Email = "*****@*****.**", Phone = "12345678", CreditStanding = 200, BillingAddress = "Gade 1B, Tyskland", ShippingAddress = "Gade 1B, Tyskland" }, new Customer { CustomerId = 3, FullName = "Louise Pedersen", Email = "*****@*****.**", Phone = "12345678", CreditStanding = 0, BillingAddress = "Gade 1B, Tyskland", ShippingAddress = "Gade 1B, Tyskland" }, new Customer { CustomerId = 4, FullName = "Frederika Laudsen", Email = "*****@*****.**", Phone = "12345678", CreditStanding = 5500, BillingAddress = "Gade 1B, Tyskland", ShippingAddress = "Gade 1B, Tyskland" }, new Customer { CustomerId = 5, FullName = "Hans Peder", Email = "*****@*****.**", Phone = "12345678", CreditStanding = 2500, BillingAddress = "Gade 1B, Tyskland", ShippingAddress = "Gade 1B, Tyskland" } }; context.Customers.AddRange(customers); context.SaveChanges(); }
// This method will create and seed the database. public static void Initialize(CustomerApiContext context) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); // Look for any Customers if (context.Customers.Any()) { return; // DB has been seeded } List <Customer> customers = new List <Customer> { new Customer { CompanyName = "Company1", Email = "*****@*****.**", BillingAddress = "Home1" }, new Customer { CompanyName = "Company2", Email = "*****@*****.**", BillingAddress = "Home2" }, new Customer { CompanyName = "Company3", Email = "*****@*****.**", BillingAddress = "Home3" } }; context.Customers.AddRange(customers); context.SaveChanges(); }
public static void Initialize(CustomerApiContext context) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); // Look for any Products if (context.Customers.Any()) { return; // DB has been seeded } var Address1 = new Address() { Id = 1, City = "Esbjerg", Country = "Danmark", StreetName = "Fynsgade 33", ZipCode = 6700 }; var Address2 = new Address() { Id = 2, City = "Esbjerg", Country = "Danmark", StreetName = "Tarp byvej 50", ZipCode = 6715 }; List <Customer> customers = new List <Customer> { new Customer { RegNo = 1, Email = "*****@*****.**", Phone = "12345678", CompanyName = "Some Company A/S", BillingAddress = Address1, ShippingAddress = Address1 }, new Customer { RegNo = 2, Email = "*****@*****.**", Phone = "87654321", CompanyName = "Some Other Company A/S", ShippingAddress = Address2, BillingAddress = Address2 } }; context.Customers.AddRange(customers); context.SaveChanges(); }
// This method will create and seed the database. public static void Initialize(CustomerApiContext context) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); //// Look for any Products //if (context.Orders.Any()) //{ // return; // DB has been seeded //} //List<Order> orders = new List<Order> //{ // new Order { Date = DateTime.Today, ProductId = 1, Quantity = 2 } //}; //context.Orders.AddRange(orders); context.SaveChanges(); }
// This method will create and seed the database. public static void Initialize(CustomerApiContext context) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); // Look for any Products if (context.Customers.Any()) { return; // DB has been seeded } List <Customer> customers = new List <Customer> { new Customer { BillingAddress = "Havnegade 63 B, 6700, Esbjerg", CompanyName = "EASV", Email = "*****@*****.**", Phone = "1345 5684", ShippingAddress = "Havnegade 63 B, 6700, Esbjerg" } }; context.Customers.AddRange(customers); context.SaveChanges(); }
// This method will create and seed the database. public static void Initialize(CustomerApiContext context) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); //// Look for any Products //if (context.Orders.Any()) //{ // return; // DB has been seeded //} List <Customer> orders = new List <Customer> { new Customer { CompanyName = "Cardboard Murders Inc.", Email = "*****@*****.**", ShippingAddress = new Address() { City = "Nowhere", StreetAddress = "Cardboard box at the corner of 53rd and 22nd", ZipCode = "????" }, Phone = "Payphone at 53rd st", BillingAddress = new Address() { City = "Washington, DC", StreetAddress = "The White House, 1600 Pennsylvania Ave NW", ZipCode = "20500" } } }; context.Customers.AddRange(orders); context.SaveChanges(); }
// This method will create and seed the database. public void Initialize(CustomerApiContext context) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); if (context.Customers.Any()) { // Check if DB has been seeded. return; } List <Customer> customers = new List <Customer> { new Customer { Id = 1, Name = "customer1", Email = "*****@*****.**", PhoneNumber = "1234", BillingAddress = "billingAddress1", ShippingAddress = "shippingAddress1", CreditStanding = true }, new Customer { Id = 2, Name = "customer2", Email = "*****@*****.**", PhoneNumber = "5678", BillingAddress = "billingAddress2", ShippingAddress = "shippingAddress2", CreditStanding = false } }; context.Customers.AddRange(customers); context.SaveChanges(); }
public void SeedWithData(CustomerApiContext CustomerApiContext) { /// Deleting & Creating DB - memory CustomerApiContext.Database.EnsureDeleted(); CustomerApiContext.Database.EnsureCreated(); List <Customer> Customers = new List <Customer>() { new Customer() { Name = "Bent Jorgen", VATNumber = "12345678" }, new Customer() { Name = "Hussain Larsen", VATNumber = "87654321" } }; CustomerApiContext.Customers.AddRange(Customers); CustomerApiContext.SaveChanges(); }
// This method will create and seed the database. public static void Initialize(CustomerApiContext context) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); // Look for any Customers if (context.Customers.Any()) { return; // DB has been seeded } List <Customer> customers = new List <Customer> { new Customer { Name = "Jhon Doe", RegistrationNumber = 1, Phone = 12313123, Email = "*****@*****.**", BillingAddress = "Youareaperfectionist street 43, Esbjerg", ShippingAddress = "Isthisbetter road 23, Esbjerg", HasOutstanding = false }, new Customer { Name = "Jhon Doe2", RegistrationNumber = 2, Phone = 12313123, Email = "*****@*****.**", BillingAddress = "Some street 11, Malmö", ShippingAddress = "Something road -1, King's Landing", HasOutstanding = true }, }; context.Customers.AddRange(customers); context.SaveChanges(); }