示例#1
0
        // GET: products/Create
        public ActionResult Create()
        {
            IOffreService offreService = new OffreService();
            ICategoryService CategoryService = new CategoryService();
          
            IEnumerable<offre> offres = offreService.GetOffres().ToList();
            offres = offres.Where(off => off.products.Count>0  &&  off.products.FirstOrDefault().owner_username.ToLower().Equals(((string)(Session["session"])).ToLower())).ToList();
            product product = new product { creationdate = DateTime.Now.Date };

            IEnumerable<category> categories = CategoryService.GetCategories().ToList();
            //categories = CategoryService.GetAllCategory().ToList();
            SelectList selectList = new SelectList(offres,"id", "name");
            product.owner_username = (string)(Session["session"]);
            SelectList selectList1 = new SelectList(categories, "id", "name");
            ViewData["offreList"] = selectList;
            ViewData["categoryList"] = selectList1;
                       return View(product);
        }
示例#2
0
        // GET: products/Edit/5
        public ActionResult Edit(long id)
        {
            IOffreService offreService = new OffreService();
            ICategoryService CategoryService = new CategoryService();
          
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            IEnumerable<offre> offres = offreService.GetOffres().ToList();
            offres = offres.Where(off => off.products.Count > 0 && off.products.FirstOrDefault().owner_username.ToLower().Equals(((string)(Session["session"])).ToLower())).ToList();
           

            IEnumerable<category> categories = CategoryService.GetCategories().ToList();
             
            SelectList selectList = new SelectList(offres, "id", "name");

            SelectList selectList1 = new SelectList(categories, "id", "name");
            ViewData["offreList"] = selectList;
            ViewData["categoryList"] = selectList1;
            product product = productServicce.FindProductById(id);
            if (product == null)
            {
                return HttpNotFound();
            }
            return View(product);
        }