Beispiel #1
0
        public static void InsertCustomer(string customerID, string companyName, string contactName = null,
               string contactTitle = null, string address = null, string city = null, string region = null,
                string postalCode = null, string country = null, string phone = null, string fax = null)
        {
            var db = new NorthwindEntities();

            using (db)
            {
                Customer customer = new Customer()
                {
                    CustomerID = customerID,
                    CompanyName = companyName,
                    ContactName = contactName,
                    ContactTitle = contactTitle,
                    Address = address,
                    City = city,
                    Region = region,
                    PostalCode = postalCode,
                    Country = country,
                    Phone = phone,
                    Fax = fax
                };

                db.Customers.Add(customer);
                db.SaveChanges();
                Console.WriteLine("Customer inserted.");

            }
        }
Beispiel #2
0
 public static void DeleteCustomer(string customerID)
 {
     var db = new NorthwindEntities();
     using (db)
     {
         var customer = db.Customers.Find(customerID);
         db.Customers.Remove(customer);
         db.SaveChanges();
         Console.WriteLine("Customer deleted.");
     }
 }
Beispiel #3
0
        public static void DeleteCustomer(string customerID)
        {
            var db = new NorthwindEntities();

            using (db)
            {
                var customer = db.Customers.Find(customerID);
                db.Customers.Remove(customer);
                db.SaveChanges();
                Console.WriteLine("Customer deleted.");
            }
        }
Beispiel #4
0
        public static void UpdateCustomer(string customerID, string companyName, string contactName = null,
                                          string contactTitle = null, string address = null, string city  = null, string region = null,
                                          string postalCode   = null, string country = null, string phone = null, string fax    = null)
        {
            var db = new NorthwindEntities();

            using (db)
            {
                var customer = db.Customers.Find(customerID);
                customer.CompanyName  = companyName;
                customer.ContactName  = contactName;
                customer.ContactTitle = contactTitle;
                customer.Address      = address;
                customer.City         = city;
                customer.Region       = region;
                customer.PostalCode   = postalCode;
                customer.Country      = country;
                customer.Phone        = phone;
                customer.Fax          = fax;

                db.SaveChanges();
                Console.WriteLine("Customer updated.");
            }
        }
Beispiel #5
0
        public static void UpdateCustomer(string customerID, string companyName, string contactName = null,
               string contactTitle = null, string address = null, string city = null, string region = null,
                string postalCode = null, string country = null, string phone = null, string fax = null)
        {
            var db = new NorthwindEntities();

            using (db)
            {

                var customer = db.Customers.Find(customerID);
                customer.CompanyName = companyName;
                customer.ContactName = contactName;
                customer.ContactTitle = contactTitle;
                customer.Address = address;
                customer.City = city;
                customer.Region = region;
                customer.PostalCode = postalCode;
                customer.Country = country;
                customer.Phone = phone;
                customer.Fax = fax;

                db.SaveChanges();
                Console.WriteLine("Customer updated.");
            }
        }