コード例 #1
0
        static void Main(string[] args)
        {
            Produit p = new Produit()
            {
            };
            ServiceProduit sp = new ServiceProduit();

            // sp.AddProduct(p);
            //sp.Commit();
            sp.Add(p);
            sp.Commit();
            Console.WriteLine("base crée");
            Console.ReadKey();
        }
コード例 #2
0
        public ActionResult Create(ProduitModel pm, HttpPostedFileBase Image)
        {
            pm.Image = Image.FileName;
            Produit p = new Produit()
            {
                Libelle      = pm.Libelle,
                Nom          = pm.Nom,
                Quantitee    = pm.Quantitee,
                Prix         = pm.Prix,
                Description  = pm.Description,
                Image        = pm.Image,
                Id_categorie = pm.Id_categorie,
                Id_boutique  = pm.Id_boutique
            };


            var path = Path.Combine(Server.MapPath("~/Content/Upload/"), Image.FileName);

            Image.SaveAs(path);



            try
            {
                // TODO: Add insert logic here
                sp.Add(p);
                // listprod.Add(p);

                // Session["Products"] = listprod;

                sp.Commit();
                return(RedirectToAction("ListeProduit"));
            }
            catch
            {
                return(View());
            }
        }