예제 #1
0
        public IHttpActionResult PutLigneCommand(int id, LigneCommand ligneCommand)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != ligneCommand.idLigneCommand)
            {
                return(BadRequest());
            }

            db.Entry(ligneCommand).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LigneCommandExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #2
0
        public int createLigneCommand(int id)
        {
            Product p = new Product
            {
                description = "dasf",
                Nom         = "ads",
                dateC       = DateTime.Today,
                dateF       = DateTime.Today
            };
            LigneCommand ligneCommand = new LigneCommand
            {
                date     = DateTime.Today,
                produit  = p,
                quantite = 1,
                panier   = panier
            };

            panierService.Add(panier);
            panierService.Commit();
            serviceProduit.Add(p);
            serviceProduit.Commit();
            ligneCommandService.Add(ligneCommand);
            ligneCommandService.Commit();



            return(0);
        }
예제 #3
0
        public IHttpActionResult GetLigneCommand(int id)
        {
            LigneCommand ligneCommand = db.LigneCommands.Find(id);

            if (ligneCommand == null)
            {
                return(Ok(new LigneCommand()));
            }

            return(Ok(ligneCommand));
        }
예제 #4
0
        public IHttpActionResult PostLigneCommand(LigneCommand ligneCommand)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.LigneCommands.Add(ligneCommand);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = ligneCommand.idLigneCommand }, ligneCommand));
        }
예제 #5
0
        public IHttpActionResult DeleteLigneCommand(int id)
        {
            LigneCommand ligneCommand = db.LigneCommands.Find(id);

            if (ligneCommand == null)
            {
                return(NotFound());
            }

            db.LigneCommands.Remove(ligneCommand);
            db.SaveChanges();

            return(Ok(ligneCommand));
        }
예제 #6
0
        public void CreateCommandLineApi(int id)
        {
            Product p = serviceProduit.HetProduct(id);

            if (ligneCommandService.exist(panier.idPanier, p.IdProduct) == 0)
            {
                LigneCommand ligneCommand = new LigneCommand
                {
                    date      = DateTime.Today,
                    ProduitId = id,
                    quantite  = 1,
                    panier    = panier
                };

                ligneCommandService.Add(ligneCommand);
                ligneCommandService.Commit();
            }
            else
            {
                ligneCommandService.Increment(panier.idPanier, p.IdProduct);
            }
        }