Ejemplo n.º 1
0
 public static DBO.Translation GetTranslationById(long id)
 {
     try
     {
         using (MeditateBookEntities bdd = new MeditateBookEntities())
         {
             T_Translation translation = bdd.T_Translation.Where(x => x.id == id).FirstOrDefault();
             if (translation != null)
             {
                 DBO.Translation newTranslation = new DBO.Translation()
                 {
                     Content      = translation.content,
                     Id           = translation.id,
                     IdArticle    = translation.id_article,
                     IdLanguage   = translation.id_language,
                     IdTranslator = translation.id_translator,
                     Validated    = translation.validated
                 };
                 return(newTranslation);
             }
             return(null);
         }
     }
     catch (Exception e)
     {
         System.Diagnostics.Debug.WriteLine(e);
         return(null);
     }
 }
Ejemplo n.º 2
0
        public static bool CreateTranslation(DBO.Translation translation)
        {
            try
            {
                using (MeditateBookEntities bdd = new MeditateBookEntities())
                {
                    T_Translation newTranslation = new T_Translation()
                    {
                        content       = translation.Content,
                        id_article    = translation.IdArticle,
                        id_language   = translation.IdLanguage,
                        id_translator = translation.IdTranslator,
                        validated     = translation.Validated
                    };

                    bdd.T_Translation.Add(newTranslation);
                    bdd.SaveChanges();
                    return(true);
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e);
                return(false);
            }
        }
Ejemplo n.º 3
0
        public static bool UpdateTranslation(DBO.Translation translation)
        {
            try
            {
                using (MeditateBookEntities bdd = new MeditateBookEntities())
                {
                    T_Translation oldTranslation = bdd.T_Translation.Where(x => x.id == translation.Id).FirstOrDefault();
                    if (oldTranslation != null)
                    {
                        oldTranslation.content       = translation.Content;
                        oldTranslation.id_article    = translation.IdArticle;
                        oldTranslation.id_language   = translation.IdLanguage;
                        oldTranslation.id_translator = translation.IdTranslator;
                        oldTranslation.validated     = translation.Validated;

                        bdd.SaveChanges();
                        return(true);
                    }
                    return(false);
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e);
                return(false);
            }
        }