public void DeleteEnd() { //var deleteOrderDetails = // from details in lContext.Persons // where details.Id == this.Id // select details; DataSource.Customer lDeleted = lContext.Customers.SingleOrDefault(p => p.Id == this.Id); if (lDeleted != null) { lContext.Customers.DeleteOnSubmit(lDeleted); try { lContext.SubmitChanges(); } catch (Exception e) { Console.WriteLine(e); // Provide for exceptions. } } }
public void EndEdit() { DataSource.Customer lUpdate = lContext.Customers.SingleOrDefault(p => p.Id == this.Id); if (lUpdate == null) { DataSource.Customer newItem = new DataSource.Customer { Id = this.Id, Contact = this.ContactId, Name = this.Name, CompanyName = this.CompanyName, DeliveryAddress = this.DeliveryAddress, BillingAddress = this.BillingAddress, Type = this.ClientTypeId, Description = this.Description }; // Add the new object to the Orders collection. lContext.Customers.InsertOnSubmit(newItem); // Submit the change to the database. try { lContext.SubmitChanges(); this.Id = newItem.Id; } catch (Exception e) { Console.WriteLine(e); } } else { lUpdate.Contact = this.ContactId; lUpdate.Name = this.Name; lUpdate.CompanyName = this.CompanyName; lUpdate.DeliveryAddress = this.DeliveryAddress; lUpdate.BillingAddress = this.BillingAddress; lUpdate.Type = this.ClientTypeId; lUpdate.Description = this.Description; lContext.SubmitChanges(); } }
public void UpdateCustomer(DataSource.Customer customer) { }