Esempio n. 1
0
        public ActionResult DeleteConfirmed(int id)
        {
            XLPro xLPro = db.XLProes.Find(id);

            db.XLProes.Remove(xLPro);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
 public ActionResult Edit([Bind(Include = "XLID,ProductID,Quantity")] XLPro xLPro)
 {
     if (ModelState.IsValid)
     {
         db.Entry(xLPro).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ProductID = new SelectList(db.Products, "ProductID", "PName", xLPro.ProductID);
     return(View(xLPro));
 }
Esempio n. 3
0
        // GET: XLProes/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            XLPro xLPro = db.XLProes.Find(id);

            if (xLPro == null)
            {
                return(HttpNotFound());
            }
            return(View(xLPro));
        }
Esempio n. 4
0
        // GET: XLProes/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            XLPro xLPro = db.XLProes.Find(id);

            if (xLPro == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ProductID = new SelectList(db.Products, "ProductID", "PName", xLPro.ProductID);
            //return View(xLPro);
            return(PartialView("../XLProes/_partialEdit", xLPro));
        }
Esempio n. 5
0
 public ActionResult Create([Bind(Include = "ProductID,PName,Price,BrandID,Status")] Product product)
 {
     if (ModelState.IsValid)
     {
         product.Status = true;
         db.Products.Add(product);
         db.SaveChanges();
         db = new ModelContext1();
         Promotion pro = new Promotion();
         pro.PromotionID = RandomString(5, true);
         pro.ProductID   = product.ProductID;
         pro.Promotion1  = 0;
         db.Promotions.Add(pro);
         db.SaveChanges();
         db = new ModelContext1();
         SPro s = new SPro();
         s.ProductID = product.ProductID;
         s.Quantity  = 0;
         db.SProes.Add(s);
         db.SaveChanges();
         db = new ModelContext1();
         LPro l = new LPro();
         l.ProductID = product.ProductID;
         l.Quantity  = 0;
         db.LProes.Add(l);
         db.SaveChanges();
         db = new ModelContext1();
         MPro m = new MPro();
         m.ProductID = product.ProductID;
         m.Quantity  = 0;
         db.MProes.Add(m);
         db.SaveChanges();
         db = new ModelContext1();
         XLPro xl = new XLPro();
         xl.ProductID = product.ProductID;
         xl.Quantity  = 0;
         db.XLProes.Add(xl);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.BrandID = new SelectList(db.Brands, "BrandID", "BName", product.BrandID);
     return(View(product));
 }
Esempio n. 6
0
        public ActionResult Create([Bind(Include = "XLID,ProductID,Quantity")] XLPro xLPro)
        {
            var sp = db.XLProes.SingleOrDefault(a => a.ProductID.Equals(xLPro.ProductID));

            if (sp == null)
            {
                if (ModelState.IsValid)
                {
                    db.XLProes.Add(xLPro);
                    db.SaveChanges();
                    return(RedirectToAction("Index", "Products"));
                }
            }
            else
            {
                sp.Quantity = sp.Quantity + xLPro.Quantity;
                db.SaveChanges();
                return(RedirectToAction("Index", "Products"));
            }

            ViewBag.ProductID = new SelectList(db.Products, "ProductID", "PName", xLPro.ProductID);
            return(View(xLPro));
        }