public static string InsertNewCustomer(Customer customer) { if (customer == null) { throw new ArgumentNullException("You can not pass null as parameter"); } using (var northwindEntities = new NorthwindEntities()) { northwindEntities.Customers.Add(customer); northwindEntities.SaveChanges(); return customer.CustomerID; } }
public static void Main() { var newCustomer = new Customer { CustomerID = "test", CompanyName = "Royal-Dutsch Shell" }; TestInsertACustomer(newCustomer); TestMoodifyCustomer(newCustomer.CustomerID); TestDeleteCustomer(newCustomer.CustomerID); }
private static void TestInsertACustomer(Customer newCustomer) { var newId = CustomersFunctionality.InsertNewCustomer(newCustomer); Console.WriteLine("Added new customer with id {0}", newId); }