public void ChangerQuantite(long NoPanier, short NewNbItems) { PPArticlesEnPanier articlesEnPanier = new PPArticlesEnPanier(); ArticleEnPanier article = articlesEnPanier.Values.Find(x => x.NoPanier == NoPanier); article.NbItems = NewNbItems; articlesEnPanier.NotifyUpdated(article); articlesEnPanier.Update(); }
public void AjouterPanier(long NoClient, long NoProduit, short NbItems) { string ret = "OK"; PPProduits produits = new PPProduits(); PPArticlesEnPanier articlesEnPanier = new PPArticlesEnPanier(); Produit produit = produits.Values.Find(x => x.NoProduit == NoProduit); ArticleEnPanier article = articlesEnPanier.Values.Find(x => x.NoProduit == produit.NoProduit && x.NoClient == NoClient); if (article != null) { int newNbItems = article.NbItems.Value + NbItems; if (newNbItems <= produit.NombreItems) { article.NbItems = (short)newNbItems; articlesEnPanier.NotifyUpdated(article); articlesEnPanier.Update(); } else { ret = "ERREUR;Impossible d'ajouter au panier"; } } else { ArticleEnPanier newArticle = new ArticleEnPanier(null) { NoPanier = articlesEnPanier.NextId(NoClient, produit.NoVendeur.Value), NoClient = NoClient, NoVendeur = produit.NoVendeur, NoProduit = produit.NoProduit, DateCreation = DateTime.Now, NbItems = NbItems }; articlesEnPanier.Add(newArticle); } Context.Response.Clear(); Context.Response.ContentType = "application/text"; Context.Response.AddHeader("content-length", ret.Length.ToString()); Context.Response.Flush(); Context.Response.Write(ret); }