/// <summary> /// Adds a new Customer /// </summary> public static Int32 AddCustomer(MVVM.DataAccess.Customer newCustomer) { MVVM_DemoDataContext context = new MVVM_DemoDataContext(); context.Customers.InsertOnSubmit(newCustomer); context.SubmitChanges(); return(newCustomer.CustomerId); }
/// <summary> /// Updates an existing Customer /// </summary> public static Boolean UpdateCustomer(MVVM.DataAccess.Customer newCustomer) { MVVM_DemoDataContext context = new MVVM_DemoDataContext(); var customerToUpdate = context.Customers.Where(c => c.CustomerId == newCustomer.CustomerId) .SingleOrDefault(); //update the values customerToUpdate.FirstName = newCustomer.FirstName; customerToUpdate.LastName = newCustomer.LastName; customerToUpdate.Email = newCustomer.Email; customerToUpdate.HomePhoneNumber = newCustomer.HomePhoneNumber; customerToUpdate.MobilePhoneNumber = newCustomer.MobilePhoneNumber; customerToUpdate.Address1 = newCustomer.Address1; customerToUpdate.Address2 = newCustomer.Address2; customerToUpdate.Address3 = newCustomer.Address3; context.SubmitChanges(); return(true); }