Esempio n. 1
0
        //Using Model binding to Bind Data from the database. But databaseInitializer is not sending the data to the database, still replicationg the cause.
        public IQueryable <ListOfProducts> GetSingleProduct([QueryString("productID")] int?productId)
        {
            var _db = new ProductOrderApplication.Models.ProductCategoryContext();
            IQueryable <ListOfProducts> query = _db.Products;

            if (productId.HasValue && productId > 0)
            {
                query = query.Where(p => p.ProductID == productId);
            }
            else
            {
                query = null;
            }
            return(query);
        }
Esempio n. 2
0
 protected void Seed(ProductCategoryContext context)
 {
     GetCategories().ForEach(c => context.CategoryOfProducts.Add(c));
     GetProducts().ForEach(async p => (await context.Products.ToListAsync()).Add(p));
 }