示例#1
0
        public static void ModifyCustomerInfo(string customerId, NORTHWNDEntities dataBase, string companyName = null, 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 customer = dataBase.Customers.FirstOrDefault(x => x.CustomerID.ToLower() == customerId.ToLower());

            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;

            dataBase.SaveChanges();
        }
示例#2
0
 public static void InsertCustomer(Customer customer, NORTHWNDEntities dataBase)
 {
     dataBase.Customers.Add(customer);
     dataBase.SaveChanges();
 }
示例#3
0
 public static void DeleteCustomer(string customerId, NORTHWNDEntities dataBase)
 {
     var customer = dataBase.Customers.FirstOrDefault(x => x.CustomerID.ToLower() == customerId.ToLower());
     dataBase.Customers.Remove(customer);
     dataBase.SaveChanges();
 }