using CD67.FicheCollege.Entity; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data.Entity; using System.Reflection; namespace CD67.FicheCollege.Factory { public partial class CollegeFactory : Internal.BaseFactory { public College clone_to_year(College college, int annee_id) { if (base.getAll().Where(c => c.Annee_Id == annee_id && c.TokenId == college.TokenId).Count() > 0) { throw new InvalidOperationException("Ce collège existe déjà pour l'année cible"); } College clone = new College(); // Nouvelle année clone.Annee_Id = annee_id; // On reprend les valeurs de tous les autres champs clone.CodeRne = college.CodeRne; clone.Libelle = college.Libelle; clone.Adresse = college.Adresse; clone.Code_Postal = college.Code_Postal; clone.TypeCollege_Id = college.TypeCollege_Id; clone.Commune_Insee = college.Commune_Insee; clone.Commune = college.Commune; clone.Canton = college.Canton; clone.Territoire_Id = college.Territoire_Id; clone.TAD = college.TAD; clone.CDC = college.CDC; clone.Tel = college.Tel; clone.Fax = college.Fax; clone.Email = college.Email; clone.PrincipalSid = college.PrincipalSid; clone.AdjointSid = college.AdjointSid; clone.Gestionnaire1Sid = college.Gestionnaire1Sid; clone.Gestionnaire2Sid = college.Gestionnaire2Sid; clone.TokenId = college.TokenId; // enregistre le clone en base base.add(ref clone); return clone; } } }