Example #1
0
 public void Update(CategorieDeProjet Entity)
 {
     if (Entity != null)
     {
         using (Crownfunding_EditionEntities Context = new Crownfunding_EditionEntities())
         {
             CategorieDeProjet Modifie = new CategorieDeProjet();
             CategorieDeProjet AUpdate = Context.CategorieDeProjet.Find(Entity.Id);
             foreach (PropertyInfo item in AUpdate.GetType().GetProperties())
             {
                 var EntityValue = Entity.GetType().GetProperty(item.Name).GetValue(Entity);
                 if (item.GetValue(AUpdate) != EntityValue)
                 {
                     Modifie.GetType().GetProperty(item.Name).SetValue(Modifie, EntityValue);
                 }
                 else
                 {
                     Modifie.GetType().GetProperty(item.Name).SetValue(Modifie, item.GetValue(AUpdate));
                 }
             }
             Context.Entry(AUpdate).CurrentValues.SetValues(Modifie);
             Context.SaveChanges();
         }
     }
     else
     {
         throw new ArgumentException("La méthode update a échoué");
     }
 }
Example #2
0
 public void Update(Utilisateur Entity)
 {
     if (Entity != null)
     {
         using (Crownfunding_EditionEntities Context = new Crownfunding_EditionEntities())
         {
             Utilisateur Modifie = new Utilisateur();
             Utilisateur AUpdate = Context.Utilisateur.Find(Entity.Id);
             foreach (PropertyInfo item in AUpdate.GetType().GetProperties())
             {
                 var EntityValue = Entity.GetType().GetProperty(item.Name).GetValue(Entity);
                 if (item.GetValue(AUpdate) != EntityValue)
                 {
                     Modifie.GetType().GetProperty(item.Name).SetValue(Modifie, EntityValue);
                 }
                 else
                 {
                     Modifie.GetType().GetProperty(item.Name).SetValue(Modifie, item.GetValue(AUpdate));
                 }
             }
             Context.Entry(AUpdate).CurrentValues.SetValues(Modifie);
             Context.SaveChanges();
         }
     }
     else
     {
         throw new ArgumentException("L'api a eu un problème");
     }
 }