Ejemplo n.º 1
0
        public bool UpdateProjectNews(ProjectNews instance)
        {
            try
            {
                ProjectNews news = Db.ProjectNews.Find(instance.ProjectNewsId);
                Type type = instance.GetType();

                foreach (var info in type.GetProperties())
                {
                    if(info.CanWrite)
                    {
                        var value = info.GetValue(instance);
                        if(value != null){
                            info.SetValue(news, value, null);
                        }
                    }
                }
                Db.SaveChanges();
                return true;
            }
            catch
            {
                return false;
            }
        }
Ejemplo n.º 2
0
 public bool CreateProjectNews(ProjectNews instance)
 {
     try
     {
         if (instance.ProjectNewsId == 0)
         {
             Db.ProjectNews.Add(instance);
             Db.SaveChanges();
             return true;
         }
         return false;
     }
     catch
     {
         return false;
     }
 }