public static void UpdateCustomer(string customerID, string newCompanyName) { NorthwindEntities db = new NorthwindEntities(); using (db) { Customer customerToUpdate = FindCustomerById(customerID); db.Entry(customerToUpdate).State = EntityState.Modified; customerToUpdate.CompanyName = newCompanyName; db.SaveChanges(); Console.WriteLine("Customer with ID:{0} UPDATED Successfully", customerID); } }
public static void DeleteCustomer(string customerID) { NorthwindEntities db = new NorthwindEntities(); using (db) { Customer customerToRemove = FindCustomerById(customerID); db.Entry(customerToRemove).State = EntityState.Deleted; db.Customers.Remove(customerToRemove); db.SaveChanges(); Console.WriteLine("Customer with ID:{0} DELETED Successfully", customerID); } }