Exemplo n.º 1
0
        public IQueryable <Category> GetCategories()
        {
            var _db = new GoEvents.Models.ProductContext();
            IQueryable <Category> query = _db.Categories;

            return(query);
        }
Exemplo n.º 2
0
        public IQueryable GetProducts()
        {
            var        _db   = new GoEvents.Models.ProductContext();
            IQueryable query = _db.Products;

            return(query);
        }
Exemplo n.º 3
0
        protected void RemoveProductButton_Click(object sender, EventArgs e)
        {
            using (var _db = new GoEvents.Models.ProductContext())
            {
                int productId = Convert.ToInt16(DropDownRemoveProduct.SelectedValue);
                var myItem    = (from c in _db.Products where c.ProductID == productId select c).FirstOrDefault();
                if (myItem != null)
                {
                    _db.Products.Remove(myItem);
                    _db.SaveChanges();

                    // Reload the page.
                    string pageUrl = Request.Url.AbsoluteUri.Substring(0, Request.Url.AbsoluteUri.Count() - Request.Url.Query.Count());
                    Response.Redirect(pageUrl + "?ProductAction=remove");
                }
                else
                {
                    LabelRemoveStatus.Text = "Unable to locate product.";
                }
            }
        }