public List <Order_Detail> GetOrderDetailForAnOrder(int orderId) { IQueryable <Order_Detail> qOrder_Detail = PersistSvr <Order_Detail> .GetAll(); List <Order_Detail> ods = (from od in qOrder_Detail where od.OrderID == orderId select od).ToList(); return(ods); }
public List <Order> GetOrderForACustomer(String customerId) { IQueryable <Order> qOrder = PersistSvr <Order> .GetAll(); List <Order> orders = (from o in qOrder where o.CustomerID == customerId select o).ToList(); return(orders); }
public void UpdateOrder(Order currentOrder, Order_Detail[] details, bool commit) { PersistSvr <Order> .Update(currentOrder, commit); foreach (var od in details) { PersistSvr <Order_Detail> .Update(od, commit); } }
public void CreateOrder(Order order, Order_Detail[] details) { PersistSvr <Order> .Insert(order, true); foreach (var od in details) { od.OrderID = order.OrderID; PersistSvr <Order_Detail> .Insert(od, true); } }
public void DeleteProduct(int productId, bool commit) { IQueryable <Product> qProduct = PersistSvr <Product> .GetAll(); List <Product> pros = (from p in qProduct where p.ProductID == productId select p).ToList(); if (pros.Count <= 0) { throw new ApplicationException("NorthwindSvr::DeleteProduct: product with Id " + productId.ToString() + " doesn't exist."); } PersistSvr <Product> .Delete(pros[0], commit); }
public void DeleteCustomer(String customerId, bool commit) { IQueryable <Customer> qCustomer = PersistSvr <Customer> .GetAll(); List <Customer> cus = (from c in qCustomer where c.CustomerID == customerId select c).ToList(); if (cus.Count <= 0) { throw new ApplicationException("NorthwindSvr::DeleteCustomer: customer with Id " + customerId + " doesn't exist."); } PersistSvr <Customer> .Delete(cus[0], commit); }
public void DeleteAnOrderDetailFromAnOrder(int orderId, int productId, bool commit) { IQueryable <Order_Detail> qOrder_Detail = PersistSvr <Order_Detail> .GetAll(); List <Order_Detail> ods = (from od in qOrder_Detail where od.ProductID == productId && od.OrderID == orderId select od).ToList(); if (ods.Count <= 0) { throw new ApplicationException( "NorthwindSvr::DeleteAnOrderDetailFromAnOrder: order detail with order id " + orderId.ToString() + " and product id: " + productId.ToString() + " doesn't exist."); } PersistSvr <Order_Detail> .Delete(ods[0], commit); }
public void DeleteOrder(int orderId, bool commit) { IQueryable <Order> qOrder = PersistSvr <Order> .GetAll(); List <Order> orders = (from o in qOrder where o.OrderID == orderId select o).ToList(); if (orders.Count <= 0) { throw new ApplicationException("NorthwindSvr::DeleteOrder: product with Id " + orderId.ToString() + " doesn't exist."); } // Delete each order detail List <Order_Detail> orderDetails = GetOrderDetailForAnOrder(orders[0].OrderID); foreach (var od in orderDetails) { DeleteAnOrderDetailFromAnOrder(orders[0].OrderID, od.ProductID, commit); } PersistSvr <Order> .Delete(orders[0], commit); }
public List <SupplierDto> GetSuppliers() { return(PersistSvr <Supplier> .GetAll().ToList().Select(c => Mapper.Map <SupplierDto>(c)).ToList()); }
public void InsertProduct(Product product, bool commit) { PersistSvr <Product> .Insert(product, commit); }
public void InsertCustomer(Customer customer, bool commit) { PersistSvr <Customer> .Insert(customer, commit); }
public void UpdateCustomer(Customer currentCustomer, bool commit) { PersistSvr <Customer> .Update(currentCustomer, commit); }
public List <Customer> GetCustomers() { return(PersistSvr <Customer> .GetAll().ToList()); }
public List <OrderDto> GetOrders() { return(PersistSvr <Order> .GetAll().ToList().Select(c => Mapper.Map <OrderDto>(c)).ToList()); }
public List <CustomerDto> GetCustomers() { return(PersistSvr <Customer> .GetAll().ToList().Select(c => Mapper.Map <CustomerDto>(c)).ToList()); }
public List <Product> GetProducts() { return(PersistSvr <Product> .GetAll().ToList()); }
public List <Order> GetOrders() { return(PersistSvr <Order> .GetAll().ToList()); }
public Product GetProductById(int id) { IQueryable <Product> pds = PersistSvr <Product> .SearchBy(p => p.ProductID == id); return(pds.Count() == 0 ? null : pds.First()); }
public List <Supplier> GetSuppliers() { return(PersistSvr <Supplier> .GetAll().ToList()); }
public void UpdateProduct(Product currentProduct, bool commit) { PersistSvr <Product> .Update(currentProduct, commit); }
public ProductDto GetProductById(int id) { var pds = PersistSvr <Product> .SearchBy(p => p.ProductID == id).ToList().Select(c => Mapper.Map <ProductDto>(c)); return(pds.Count() == 0 ? null : pds.First()); }
public List <Category> GetProductCategories() { return(PersistSvr <Category> .GetAll().ToList()); }
public List <CategoryDto> GetProductCategories() { return(PersistSvr <Category> .GetAll().ToList().Select(c => Mapper.Map <CategoryDto>(c)).ToList()); }
public void Commit() { //In our implementation, any entity's commit will do the same: commit all changes to the database // so PersistSvr<Order>.Commit() and PersistSvr<Product>.Commit() will do the same. PersistSvr <Order> .Commit(); }
public List <ProductDto> GetProducts() { return(PersistSvr <Product> .GetAll().ToList().Select(c => Mapper.Map <ProductDto>(c)).ToList()); }