Esempio n. 1
0
        public Produit ajouterProduit(Produit p)
        {
            using (var db = new Dao.ProjetContext())
            {
                db.produits.Add(p);


                db.SaveChanges();

                Panier pan = new Panier();
                pan.NombreProduits = 0;
                pan.PrixTotal      = 0;

                db.paniers.Add(pan);
                db.SaveChanges();


                ProduitCommande pc = new ProduitCommande();

                pc.PanierId  = pan.PanierId;
                pc.ProduitId = p.ProduitId;
                pc.quantite  = 20;

                db.produitCommandes.Add(pc);
                db.SaveChanges();

                return(p);
            }
        }
Esempio n. 2
0
 public void modifierLigneCommande(ProduitCommande p)
 {
     using (var db = new Dao.ProjetContext())
     {
         db.Entry(p).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
Esempio n. 3
0
 public ProduitCommande ajouterLigneDeCommande(ProduitCommande p)
 {
     using (var db = new Dao.ProjetContext())
     {
         db.produitCommandes.Add(p);
         db.SaveChanges();
         return(p);
     }
 }
 public ProduitCommande ModifierLigneCommande(ProduitCommande p)
 {
     using (var bdd = new ApplicationContext())
     {
         bdd.Entry(p).State = EntityState.Modified;
         bdd.SaveChanges();
         return(p);
     }
 }
 public ProduitCommande AjouterLigneCommande(ProduitCommande p)
 {
     using (var bdd = new ApplicationContext())
     {
         bdd.produitCommandes.Add(p);
         bdd.SaveChanges();
         return(p);
     }
 }
Esempio n. 6
0
        public void CreateNewProduitCommands(ProduitCommandeDto produitCommandeDto)
        {
            ProduitCommande prodCommande = new ProduitCommande()
            {
                Quantite = produitCommandeDto.Quantite,
                Produit  = Context.Produit.Where(p => p.Id == produitCommandeDto.Produit.Id).FirstOrDefault(),
                Commande = Context.Commande.Where(c => c.Id == produitCommandeDto.Commande.Id).FirstOrDefault(),
            };

            Context.ProduitCommande.Add(prodCommande);
            Context.SaveChanges();
        }