Exemple #1
0
        public ActionResult Krijo(Brand b)
        {
            var db = new ProveDbContex();

            db.Brands.Add(b);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult Krijo(Category cat)
        {
            var db = new ProveDbContex();

            db.Categories.Add(cat);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult Ndrysho(Category cat)
        {
            var      db = new ProveDbContex();
            Category ct = db.Categories.Where(tmp => tmp.CategoryID == cat.CategoryID).FirstOrDefault();

            ct.CategoryName = cat.CategoryName;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #4
0
        public ActionResult Ndrysho(Brand br)
        {
            var   db  = new ProveDbContex();
            Brand br1 = db.Brands.Where(tmp => tmp.BrandID == br.BrandID).FirstOrDefault();

            br1.BrandName = br.BrandName;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #5
0
        public ActionResult Fshi(Brand br)
        {
            var   db  = new ProveDbContex();
            Brand br1 = db.Brands.Where(tmp => tmp.BrandID == br.BrandID).FirstOrDefault();

            db.Brands.Remove(br1);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult Delete(long id, Product p)
        {
            ProveDbContex db = new ProveDbContex();
            Product       existingProduct = db.Products.Where(temp => temp.ProductID == id).FirstOrDefault();

            db.Products.Remove(existingProduct);
            db.SaveChanges();
            return(RedirectToAction("Index", "Products"));
        }
        public ActionResult Edit(Product p)
        {
            ProveDbContex db = new ProveDbContex();
            Product       existingProduct = db.Products.Where(temp => temp.ProductID == p.ProductID).FirstOrDefault();

            existingProduct.ProductName        = p.ProductName;
            existingProduct.Price              = p.Price;
            existingProduct.DateOfPurchase     = p.DateOfPurchase;
            existingProduct.CategoryID         = p.CategoryID;
            existingProduct.BrandID            = p.BrandID;
            existingProduct.AvailabilityStatus = p.AvailabilityStatus;
            existingProduct.Active             = p.Active;
            db.SaveChanges();
            return(RedirectToAction("Index", "Products"));
        }
        public ActionResult Create(Product p)
        {
            ProveDbContex db = new ProveDbContex();

            if (Request.Files.Count >= 1)
            {
                var file     = Request.Files[0];
                var imgBytes = new Byte[file.ContentLength];
                file.InputStream.Read(imgBytes, 0, file.ContentLength);
                var base64String = Convert.ToBase64String(imgBytes, 0, imgBytes.Length);
                p.Photo = base64String;
            }
            db.Products.Add(p);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }