Beispiel #1
0
        internal void Modifier(Article article)
        {
            using (foodtruckEntities db = new foodtruckEntities())
            {
                Article articleAModifier = (from art in db.Article
                                            where art.Id == article.Id
                                            select art).FirstOrDefault();

                articleAModifier.Nom         = article.Nom;
                articleAModifier.Description = article.Description;
                articleAModifier.PrixTTC     = article.PrixTTC;
                articleAModifier.Allergenes  = article.Allergenes;
                articleAModifier.DansCarte   = article.DansCarte;
                articleAModifier.FamilleId   = article.FamilleId;
                articleAModifier.Grammage    = article.Grammage;
                articleAModifier.Litrage     = article.Litrage;
                articleAModifier.Image       = article.Image;
                try
                {
                    db.SaveChanges();
                }
                catch (Exception ex)
                {
                    string messageErreur = DALExceptions.HandleException(ex);
                    throw new Exception(messageErreur);
                }
            }
        }
Beispiel #2
0
 /// <summary>
 /// Ajoute l'article lArticle en base
 /// </summary>
 /// <param name="article"></param>
 internal void Ajouter(Article article)
 {
     using (foodtruckEntities db = new foodtruckEntities())
     {
         db.Article.Add(article);
         try
         {
             db.SaveChanges();
         }
         catch (Exception ex)
         {
             string messageErreur = DALExceptions.HandleException(ex);
             throw new Exception(messageErreur);
         }
     }
 }