Пример #1
0
 public static bool CreateLanguage(DBO.Language language)
 {
     try
     {
         using (MeditateBookEntities bdd = new MeditateBookEntities())
         {
             T_Language newLanguage = new T_Language()
             {
                 name      = language.Name,
                 shortname = language.ShortName
             };
             bdd.T_Language.Add(newLanguage);
             bdd.SaveChanges();
             return(true);
         }
     }
     catch (Exception e)
     {
         System.Diagnostics.Debug.WriteLine(e);
         return(false);
     }
 }
Пример #2
0
 public static bool UpdateLanguage(DBO.Language language)
 {
     try
     {
         using (MeditateBookEntities bdd = new MeditateBookEntities())
         {
             T_Language oldLanguage = bdd.T_Language.Where(x => x.id == language.Id).FirstOrDefault();
             if (oldLanguage != null)
             {
                 oldLanguage.name      = language.Name;
                 oldLanguage.shortname = language.ShortName;
                 bdd.SaveChanges();
                 return(true);
             }
             return(false);
         }
     }
     catch (Exception e)
     {
         System.Diagnostics.Debug.WriteLine(e);
         return(false);
     }
 }
Пример #3
0
        public static DBO.Language GetLanguageById(int id)
        {
            try
            {
                using (MeditateBookEntities bdd = new MeditateBookEntities())
                {
                    T_Language language = bdd.T_Language.Where(x => x.id == id).FirstOrDefault();

                    DBO.Language newLang = new DBO.Language()
                    {
                        Name      = language.name,
                        Id        = language.id,
                        ShortName = language.shortname
                    };

                    return(newLang);
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e);
                return(null);
            }
        }