コード例 #1
0
        /// <summary>
        /// Method to get the products from an order
        /// </summary>
        /// <param name="orderId">The id of the order to get the products from</param>
        public IEnumerable <BusinessLibrary.Product> GetOrderDetails(int orderId)
        {
            List <BusinessLibrary.Product> orderProductsList = new List <BusinessLibrary.Product>();

            IQueryable <Entity.Entities.OrderProduct> orders = _dbContext.OrderProducts.Include(x => x.Product).Where(x => x.OrderId == orderId);

            foreach (var p in orders)
            {
                BusinessLibrary.Product prod = new BusinessLibrary.Product(p.ProductId, p.Product.Name, (double)p.ProductPricePaid, p.ProductQty);
                orderProductsList.Add(prod);
            }

            return(orderProductsList);
        }
コード例 #2
0
        /// <summary>
        /// Method to get a stores product inventory
        /// </summary>
        /// <param name="l">The stores location object</param>
        public IEnumerable <BusinessLibrary.Product> GetStoreInventory(BusinessLibrary.StoreLocation l)
        {
            //return list to hold all the products
            List <BusinessLibrary.Product> products = new List <BusinessLibrary.Product>();

            //get products from invetory of selected location
            IQueryable <Entity.Entities.StoreInventory> inventory = _dbContext.StoreInventories.Include(x => x.Product)
                                                                    .Where(x => x.LocationId == l.StoreLocationId + 1);

            //add each product to list
            foreach (var item in inventory)
            {
                BusinessLibrary.Product p = new BusinessLibrary.Product(item.ProductId, item.Product.Name, (double)item.Product.Price, item.ProductQty);
                products.Add(p);
            }

            return(products);
        }