Ejemplo n.º 1
0
        // GET: Products/Details/5
        public ActionResult Details(int id)
        {
            IserviceProduct ip = new serviceProduct();
            Product         p  = ip.GetById(id);

            return(View(p));
        }
Ejemplo n.º 2
0
        // GET: Products
        public ActionResult Index()
        {
            IserviceProduct ip = new serviceProduct();
            List <Product>  lp = new List <Product>();

            lp = ip.listprod();

            return(View(lp));
        }
Ejemplo n.º 3
0
        // GET: Products
        public ActionResult Index()
        {
            IserviceProduct ip = new serviceProduct();
            List <Product>  lp = new List <Product>();

            lp = ip.listprod();
            lp.Reverse();

            ViewBag.pagenb = lp.Count / 12;
            return(View(lp));
        }
Ejemplo n.º 4
0
        public PartialViewResult Products()
        {
            serviceProduct ip = new serviceProduct();

            List <Product> lp = new List <Product>();

            lp = ip.GetMany().Reverse().Where(a => a.qteprod > 0).Take(6).ToList();

            ViewData["list"] = lp;
            return(PartialView());
        }
Ejemplo n.º 5
0
        public ActionResult Index(string search, string type)
        {
            IserviceProduct ip = new serviceProduct();

            string         ch  = search; //valeur à chercher
            string         ch1 = type;   //type de trie
            List <Product> lp  = ip.search_kw(search).Where(a => a.qteprod > 0).ToList();

            if (type.Equals("desc"))
            {
                lp.Reverse();
            }

            return(View(lp));
        }
Ejemplo n.º 6
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));
        }
Ejemplo n.º 7
0
        public ActionResult Index(string search, string type, string btPage)
        {//this method maymeshaa haad w manajemch nfasarha li yheb yefhemha nfahemhelou ki net9ablou
            IserviceProduct ip = new serviceProduct();
            List <Product>  lp = new List <Product>();

            if (type != null)
            {
                string ch  = search; //valeur à chercher
                string ch1 = type;   //type de trie
                lp = ip.search_kw(search).Where(a => a.qteprod > 0).ToList();
                if (!type.Equals("desc"))
                {
                    lp.Reverse();
                    order = true;
                }
                else
                {
                    order = false;
                }
            }
            else
            {
                int page = Int32.Parse(btPage);

                lp = ip.listprod();
                if (order)
                {
                    lp.Reverse();
                    lp = lp.Skip((page - 1) * 12).ToList();
                }
                else
                {
                    lp = lp.Skip((page - 1) * 12).ToList();
                }
            }
            ViewBag.pagenb = ip.listprod().Count / 12;
            return(View(lp));
        }
Ejemplo n.º 8
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 }));
            }
        }