예제 #1
0
파일: DAO.cs 프로젝트: nzhul/TelerikAcademy
 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);
     }
 }
예제 #2
0
파일: DAO.cs 프로젝트: nzhul/TelerikAcademy
 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);
     }
 }