void IProductService.Delete(int ProductID) { using (var context = new DataBaseEntities(DBManager.EntityConnectionString)) { Product oldProduct = context.Products.Where(i => i.ProductID == ProductID).First(); context.DeleteObject(oldProduct); context.SaveChanges(); } }
void IOrderService.Delete(int OrderID) { using (var context = new DataBaseEntities(DBManager.EntityConnectionString)) { Order oldOrder = context.Orders.Where(i => i.OrderID == OrderID).First(); context.DeleteObject(oldOrder); context.SaveChanges(); } }
void IDeviceService.Delete(int DeviceId) { using (var context = new DataBaseEntities(DBManager.EntityConnectionString)) { Device oldDevice = context.Devices.Where(i => i.DeviceID == DeviceId).First(); context.DeleteObject(oldDevice); context.SaveChanges(); } }
void ICustomerService.Delete(int CustomerID) { using (var context = new DataBaseEntities()) { try { Customer cust = context.Customers .Where(c => c.CustomerID == CustomerID) .FirstOrDefault(); context.DeleteObject(cust); context.SaveChanges(); } catch (Exception) { throw new FaultException("Error deleting customer id#" + CustomerID); } } }