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;
            }
        }
示例#2
0
        public static void Main()
        {
            var newCustomer = new Customer
            {
                CustomerID = "test",
                CompanyName = "Royal-Dutsch Shell"
            };

            TestInsertACustomer(newCustomer);

            TestMoodifyCustomer(newCustomer.CustomerID);

            TestDeleteCustomer(newCustomer.CustomerID);
        }
示例#3
0
        private static void TestInsertACustomer(Customer newCustomer)
        {
            var newId = CustomersFunctionality.InsertNewCustomer(newCustomer);

            Console.WriteLine("Added new customer with id {0}", newId);
        }