コード例 #1
0
        // GET: Products/Details/5
        public ActionResult Details(int id)
        {
            IserviceProduct ip = new serviceProduct();
            Product         p  = ip.GetById(id);

            return(View(p));
        }
コード例 #2
0
        // GET: Products/Details/5

        public ActionResult Details(int id, bool?stock, bool?error, bool?success)
        {
            IserviceProduct ip = new serviceProduct();
            Product         p  = ip.GetById(id);

            if (stock != null && stock == true)
            {
                ViewBag.stock = "not enough quantity in the stock";
            }
            if (error != null && error == true)
            {
                ViewBag.error = "be sure to check your informations all fields are required";
            }
            if (success != null && success == true)
            {
                ViewBag.success = "your order is registred you will be contacted for delivery informations";
            }
            return(View(p));
        }
コード例 #3
0
        public ActionResult Delete(int id)
        {
            Product p = sp.GetById(id);

            Console.WriteLine("------------" + Path.Combine(Server.MapPath("/Content/stickerspic/"), p.imgprod));
            System.IO.File.Delete(Server.MapPath("/Content/stickerspic/") + p.imgprod);
            Console.WriteLine(Path.Combine(Server.MapPath("/Content/stickerspic/"), p.imgprod));
            if (p.img1 != null && p.img1 != "")
            {
                System.IO.File.Delete(Server.MapPath("/Content/stickerspic/") + p.img1);
            }
            if (p.img2 != null && p.img2 != "")
            {
                System.IO.File.Delete(Server.MapPath("/Content/stickerspic/") + p.img2);
            }
            if (p.img3 != null && p.img3 != "")
            {
                System.IO.File.Delete(Server.MapPath("/Content/stickerspic/") + p.img3);
            }
            sp.deleteprod(id);
            return(RedirectToAction("IndexProducts", "Admin"));
        }
コード例 #4
0
        public ActionResult Command(Command cmd)
        {
            bool stock   = false;
            bool error   = false;
            bool success = false;

            ViewData.Clear();
            if (cmd.phone2 == null)
            {
                ModelState.AddModelError("", "phone2 required");
            }

            IserviceProduct ps = new serviceProduct();
            Product         p  = ps.GetById(cmd.idprod);

            if (p.qteprod < cmd.qteprod)
            {
                ModelState.AddModelError("quantity not enough", "not enough quantity in the stock");

                stock = true;
                return(RedirectToAction("Details/" + cmd.idprod, "Products", new { stock = stock }));
            }

            if (ModelState.IsValid)
            {
                //if modelstate is valid then add_command check service command for more informations
                IserviceCommand spc = new serviceCommand();
                spc.add_commande(cmd);
                success = true;
                return(RedirectToAction("Details/" + cmd.idprod, "Products", new { success = success }));
            }
            else
            {
                error = true;
                return(RedirectToAction("Details/" + cmd.idprod, "Products", new { error = error }));
            }
        }
コード例 #5
0
 public ActionResult DetailProd(int id)
 {
     //detail prod for admin that means without add command option
     //this one have no view create the view
     return(View(sp.GetById(id)));
 }
コード例 #6
0
 // GET: Products/Edit/5
 public ActionResult Edit(int id)
 {
     //request a product by id and returning the product model in the view
     return(View(sp.GetById(id)));
 }