public Employee CreateEmployee(Employee employee)
 {
     var dc = new DataClassesDataContext(_connectionString);
     dc.Employees.InsertOnSubmit(employee);
     dc.SubmitChanges();
     return employee;
 }
 public Category CreateCategory(Category category)
 {
     var dc = new DataClassesDataContext(_connectionString);
     dc.Categories.InsertOnSubmit(category);
     dc.SubmitChanges();
     return category;
 }
 public Customer CreateCustomer(Customer customer)
 {
     var dc = new DataClassesDataContext(_connectionString);
     dc.Customers.InsertOnSubmit(customer);
     dc.SubmitChanges();
     return customer;
 }
 public Product CreateProduct(Product product)
 {
     var dc = new DataClassesDataContext(_connectionString);
     if (product.Category != null)
     {
         dc.Categories.Attach(product.Category, false);
     }
     if (product.Supplier != null)
     {
         dc.Suppliers.Attach(product.Supplier, false);
     }
     dc.Products.InsertOnSubmit(product);
     dc.SubmitChanges();
     return product;
 }
 public Order CreateOrder(Order order)
 {
     var dc = new DataClassesDataContext(_connectionString);
     if (order.Shipper != null)
     {
         dc.Shippers.Attach(order.Shipper, false);
     }
     if (order.Customer != null)
     {
         dc.Customers.Attach(order.Customer, false);
     }
     if (order.Employee != null)
     {
         dc.Employees.Attach(order.Employee, false);
     }
     dc.Orders.InsertOnSubmit(order);
     dc.SubmitChanges();
     return order;
 }
 public Supplier UpdateSupplier(Supplier supplier)
 {
     var dc = new DataClassesDataContext(_connectionString);
     dc.Suppliers.Attach(supplier, ReadSupplier(supplier.SupplierID));
     dc.SubmitChanges();
     return supplier;
 }
 public Product UpdateProduct(Product product)
 {
     var dc = new DataClassesDataContext(_connectionString);
     dc.Products.Attach(product, ReadProduct(product.ProductID));
     dc.SubmitChanges();
     return product;
 }
 public Order UpdateOrder(Order order)
 {
     var dc = new DataClassesDataContext(_connectionString);
     dc.Orders.Attach(order, ReadOrder(order.OrderID));
     dc.SubmitChanges();
     return order;
 }
 public Employee UpdateEmployee(Employee employee)
 {
     var dc = new DataClassesDataContext(_connectionString);
     dc.Employees.Attach(employee, ReadEmployee(employee.EmployeeID));
     dc.SubmitChanges();
     return employee;
 }
 public void DeleteCustomer(Customer customer)
 {
     var dc = new DataClassesDataContext(_connectionString);
     IQueryable<Customer> s = from e in dc.Customers
                              where e.CustomerID == customer.CustomerID
                              select e;
     dc.Customers.DeleteOnSubmit(s.First());
     dc.SubmitChanges();
 }
 public Category UpdateCategory(Category category)
 {
     var dc = new DataClassesDataContext(_connectionString);
     dc.Categories.Attach(category, ReadCategory(category.CategoryID));
     dc.SubmitChanges();
     return category;
 }
 public void DeleteSupplier(Supplier supplier)
 {
     var dc = new DataClassesDataContext(_connectionString);
     IQueryable<Supplier> s = from e in dc.Suppliers
                              where e.SupplierID == supplier.SupplierID
                              select e;
     dc.Suppliers.DeleteOnSubmit(s.First());
     dc.SubmitChanges();
 }
 public void DeleteProduct(Product product)
 {
     var dc = new DataClassesDataContext(_connectionString);
     IQueryable<Product> s = from e in dc.Products
                             where e.ProductID == product.ProductID
                             select e;
     dc.Products.DeleteOnSubmit(s.First());
     dc.SubmitChanges();
 }
 public void DeleteEmployee(Employee employee)
 {
     var dc = new DataClassesDataContext(_connectionString);
     IQueryable<Employee> s = from e in dc.Employees
                              where e.EmployeeID == employee.EmployeeID
                              select e;
     dc.Employees.DeleteOnSubmit(s.First());
     dc.SubmitChanges();
 }
 public Customer UpdateCustomer(Customer customer)
 {
     var dc = new DataClassesDataContext(_connectionString);
     dc.Customers.Attach(customer, ReadCustomer(customer.CustomerID));
     dc.SubmitChanges();
     return customer;
 }
 public Supplier CreateSupplier(Supplier supplier)
 {
     var dc = new DataClassesDataContext(_connectionString);
     dc.Suppliers.InsertOnSubmit(supplier);
     dc.SubmitChanges();
     return supplier;
 }
 public void DeleteCategory(Category category)
 {
     var dc = new DataClassesDataContext(_connectionString);
     IQueryable<Category> s = from e in dc.Categories
                              where e.CategoryID == category.CategoryID
                              select e;
     dc.Categories.DeleteOnSubmit(s.First());
     dc.SubmitChanges();
 }