Пример #1
0
        public IQueryable <Category> GetCategories()
        {
            var _db = new ShoppingCart.Models.ProductContext();
            IQueryable <Category> query = _db.categories;

            return(query);
        }
Пример #2
0
 public void Dispose()
 {
     if (_db != null)
     {
         _db.Dispose();
         _db = null;
     }
 }
Пример #3
0
        public IQueryable <Product> GetProducts([QueryString("id")] int?categoryId)
        {
            var _db = new ShoppingCart.Models.ProductContext();
            IQueryable <Product> query = _db.products;

            if (categoryId.HasValue && categoryId > 0)
            {
                query = query.Where(p => p.CategoryID == categoryId);
            }
            return(query);
        }
Пример #4
0
        public IQueryable <Product> GetProducts(
            [QueryString("id")] int?categoryId,
            [RouteData] string categoryName)
        {
            var _db = new ShoppingCart.Models.ProductContext();
            IQueryable <Product> query = _db.Products;

            if (categoryId.HasValue && categoryId > 0)
            {
                query = query.Where(p => p.CategoryID == categoryId);
            }

            if (!String.IsNullOrEmpty(categoryName))
            {
                query = query.Where(p =>
                                    String.Compare(p.Category.CategoryName,
                                                   categoryName) == 0);
            }
            return(query);
        }
Пример #5
0
        public IQueryable <Product> GetProduct(
            [QueryString("ProductID")] int?productId,
            [RouteData] string productName)
        {
            var _db = new ShoppingCart.Models.ProductContext();
            IQueryable <Product> query = _db.Products;

            if (productId.HasValue && productId > 0)
            {
                query = query.Where(p => p.ProductID == productId);
            }
            else if (!String.IsNullOrEmpty(productName))
            {
                query = query.Where(p =>
                                    String.Compare(p.ProductName, productName) == 0);
            }
            else
            {
                query = null;
            }
            return(query);
        }