Exemplo n.º 1
0
        protected override IEnumerable <Language> MassClone(TestProjectEntities1 ec)
        {
            var result = new List <Language>();
            var list   = ec.tb_language.Select(item =>
                                               new Language
            {
                ID   = item.id,
                Name = item.name
            }).ToList();

            result.AddRange(list);
            return(result);
        }
Exemplo n.º 2
0
 public static bool SaveChanges(TestProjectEntities1 ec)
 {
     try
     {
         ec.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         Log.Add(ex.ToString());
         return(false);
     }
 }
Exemplo n.º 3
0
        protected override IEnumerable <User> MassClone(TestProjectEntities1 ec)
        {
            var         result = new List <User>();
            List <User> list   = ec.tb_user.Select(item =>
                                                   new User
            {
                ID           = item.id,
                Name         = item.name,
                CreationDate = item.creation_date,
                LanguageId   = item.language_id
            }).ToList();

            result.AddRange(list);
            return(result);
        }
Exemplo n.º 4
0
 public static T Connect <T>(Func <TestProjectEntities1, T> func)
 {
     try
     {
         using (var ec = new TestProjectEntities1())
         {
             return(func(ec));
         }
     }
     catch (Exception ex)
     {
         Log.Add(ex.ToString());
         return(default(T));
     }
 }
Exemplo n.º 5
0
        public static bool Delete(int id)
        {
            using (var ec = new TestProjectEntities1())
            {
                var tbUser = ec.tb_user.FirstOrDefault(i => i.id == id);
                if (tbUser == null)
                {
                    return(false);
                }

                ec.tb_user.Remove(tbUser);
                EntityConnector.SaveChanges(ec);

                return(true);
            }
        }
Exemplo n.º 6
0
        public static bool Add(User user)
        {
            using (var ec = new TestProjectEntities1())
            {
                var tbUser = new tb_user
                {
                    name          = user.Name,
                    language_id   = user.LanguageId,
                    creation_date = DateTime.Now,
                };
                ec.tb_user.Add(tbUser);
                EntityConnector.SaveChanges(ec);

                return(true);
            }
        }
Exemplo n.º 7
0
 public static void Add(string result)
 {
     try
     {
         using (var ec = new TestProjectEntities1())
         {
             var log = new tb_log
             {
                 date   = DateTime.Now,
                 result = result,
             };
             ec.tb_log.Add(log);
             EntityConnector.SaveChanges(ec);
         }
     }
     catch (Exception ex)
     {
         //add saving to text file
     }
 }
 protected abstract IEnumerable<TDirectory> MassClone(TestProjectEntities1 ec);