Exemple #1
0
 public static bool CreateArticleAttach(DBO.ArticleAttach articleAttach)
 {
     try
     {
         using (MeditateBookEntities bdd = new MeditateBookEntities())
         {
             T_Article_Attach newArticleAttach = new T_Article_Attach()
             {
                 id_article = articleAttach.IdArticle,
                 file_path  = articleAttach.FilePath,
                 name       = articleAttach.Name
             };
             bdd.T_Article_Attach.Add(newArticleAttach);
             bdd.SaveChanges();
             return(true);
         }
     }
     catch (Exception e)
     {
         System.Diagnostics.Debug.WriteLine(e);
         return(false);
     }
 }
Exemple #2
0
 public static bool UpdateArticleAttach(DBO.ArticleAttach articleAttach)
 {
     try
     {
         using (MeditateBookEntities bdd = new MeditateBookEntities())
         {
             T_Article_Attach old = bdd.T_Article_Attach.Where(x => x.id == articleAttach.Id).FirstOrDefault();
             if (old != null)
             {
                 old.id_article = articleAttach.IdArticle;
                 old.file_path  = articleAttach.FilePath;
                 old.name       = articleAttach.Name;
                 bdd.SaveChanges();
                 return(true);
             }
             return(false);
         }
     }
     catch (Exception e)
     {
         System.Diagnostics.Debug.WriteLine(e);
         return(false);
     }
 }