Esempio n. 1
0
        public IQueryable GetProducts()
        {
            var        _db   = new ProjektRWA.Models.ArtikalContext();
            IQueryable query = _db.Artikli;

            return(query);
        }
Esempio n. 2
0
        public IQueryable GetCategories()
        {
            var        _db   = new ProjektRWA.Models.ArtikalContext();
            IQueryable query = _db.Kategorije;

            return(query);
        }
Esempio n. 3
0
        protected void RemoveProductButton_Click(object sender, EventArgs e)
        {
            using (var _db = new ProjektRWA.Models.ArtikalContext())
            {
                int productId = Convert.ToInt16(DropDownRemoveProduct.SelectedValue);
                var myItem    = (from c in _db.Artikli where c.ArtikalID == productId select c).FirstOrDefault();
                if (myItem != null)
                {
                    _db.Artikli.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.";
                }
            }
        }