Ejemplo n.º 1
0
        public void detAbonnement_InsertItem()
        {
            var ab = new AppPrincipale.Models.Abonnement();

            TryUpdateModel(ab);
            if (ModelState.IsValid)
            {
                db.Abonnements.Add(ab);
                db.SaveChanges();

                divSucces.InnerText =
                    $"Merci de vous être abonné, {ab.Nom}. Vous pouvez abonner un ami.";
                divSucces.Visible = true;
            }
        }
Ejemplo n.º 2
0
        // The id parameter name should match the DataKeyNames value set on the control
        public void grdAbonnes_UpdateItem(int AbonnementId)
        {
            AppPrincipale.Models.Abonnement ab = null;
            ab = db.Abonnements.Find(AbonnementId);

            if (ab == null)
            {
                // The item wasn't found
                ModelState.AddModelError("", String.Format("Item with id {0} was not found", AbonnementId));
                return;
            }
            TryUpdateModel(ab);
            if (ModelState.IsValid)
            {
                db.SaveChanges();
            }
        }