Пример #1
0
        public IActionResult AddBeer(BeerFormViewModel addedBeer)
        {
            BeerBDD beerBDD = new BeerBDD();

            addedBeer.Categories = populateCategorie();
            addedBeer.Gammes     = populateGamme();

            IActionResult retour = null;

            if (ModelState.IsValid)
            {
                Beer beer = new Beer();

                beer.Identifiant          = addedBeer.Identifiant;
                beer.Libelle              = addedBeer.Libelle;
                beer.DateProduction       = addedBeer.DateProduction;
                beer.TauxAlcoolemie       = float.Parse(addedBeer.TauxAlcoolemie);
                beer.IdentifiantCategorie = addedBeer.IdentifiantCategorie;
                beer.IdentifiantGamme     = addedBeer.IdentifiantGamme;
                beer.Commentaire          = addedBeer.Commentaire;


                bool isOK = beerBDD.Insert(beer);
                retour = RedirectToAction("Index");
            }
            else
            {
                retour = View(addedBeer);
            }
            return(retour);
        }
Пример #2
0
        private void ValiderButton_Click(object sender, EventArgs e)
        {
            BeerBDD beerBDD = new BeerBDD();
            Beer    b       = this.beerUserControl.GetBeer();

            this.DialogResult = DialogResult.OK;

            try
            {
                beerBDD.Insert(b);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                this.DialogResult = DialogResult.Cancel;
            }

            this.Close();
        }