예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
            }
        }
예제 #4
0
        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);
            }
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
        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);
        }
예제 #8
0
        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);
        }
예제 #9
0
 public List <SupplierDto> GetSuppliers()
 {
     return(PersistSvr <Supplier> .GetAll().ToList().Select(c => Mapper.Map <SupplierDto>(c)).ToList());
 }
예제 #10
0
 public void InsertProduct(Product product, bool commit)
 {
     PersistSvr <Product> .Insert(product, commit);
 }
예제 #11
0
 public void InsertCustomer(Customer customer, bool commit)
 {
     PersistSvr <Customer> .Insert(customer, commit);
 }
예제 #12
0
 public void UpdateCustomer(Customer currentCustomer, bool commit)
 {
     PersistSvr <Customer> .Update(currentCustomer, commit);
 }
예제 #13
0
 public List <Customer> GetCustomers()
 {
     return(PersistSvr <Customer> .GetAll().ToList());
 }
예제 #14
0
 public List <OrderDto> GetOrders()
 {
     return(PersistSvr <Order> .GetAll().ToList().Select(c => Mapper.Map <OrderDto>(c)).ToList());
 }
예제 #15
0
 public List <CustomerDto> GetCustomers()
 {
     return(PersistSvr <Customer> .GetAll().ToList().Select(c => Mapper.Map <CustomerDto>(c)).ToList());
 }
예제 #16
0
 public List <Product> GetProducts()
 {
     return(PersistSvr <Product> .GetAll().ToList());
 }
예제 #17
0
 public List <Order> GetOrders()
 {
     return(PersistSvr <Order> .GetAll().ToList());
 }
예제 #18
0
        public Product GetProductById(int id)
        {
            IQueryable <Product> pds = PersistSvr <Product> .SearchBy(p => p.ProductID == id);

            return(pds.Count() == 0 ? null : pds.First());
        }
예제 #19
0
 public List <Supplier> GetSuppliers()
 {
     return(PersistSvr <Supplier> .GetAll().ToList());
 }
예제 #20
0
 public void UpdateProduct(Product currentProduct, bool commit)
 {
     PersistSvr <Product> .Update(currentProduct, commit);
 }
예제 #21
0
        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());
        }
예제 #22
0
 public List <Category> GetProductCategories()
 {
     return(PersistSvr <Category> .GetAll().ToList());
 }
예제 #23
0
 public List <CategoryDto> GetProductCategories()
 {
     return(PersistSvr <Category> .GetAll().ToList().Select(c => Mapper.Map <CategoryDto>(c)).ToList());
 }
예제 #24
0
 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();
 }
예제 #25
0
 public List <ProductDto> GetProducts()
 {
     return(PersistSvr <Product> .GetAll().ToList().Select(c => Mapper.Map <ProductDto>(c)).ToList());
 }