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é"); } }
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"); } }
public void delete() { using (Crownfunding_EditionEntities Context = new Crownfunding_EditionEntities()) { Context.NewsLetter.RemoveRange(Context.NewsLetter.ToList()); Context.SaveChanges(); } }
public CategorieDeProjet GetOne(CategorieDeProjet Entity) { if (Entity != null) { using (Crownfunding_EditionEntities Context = new Crownfunding_EditionEntities()) { return(Context.CategorieDeProjet.Find(Entity.Id)); } } else { throw new ArgumentException("Il n'y a pas de type de ce projet"); } }
public VAll_Projet GetOne(Projet Entity) { if (Entity != null && Entity.Id != 0) { using (Crownfunding_EditionEntities Context = new Crownfunding_EditionEntities()) { return(Context.VAll_Projet.Find(Mappers <Projet, VAll_Projet> .VueToEntities(Entity).Id)); } } else { throw new ArgumentOutOfRangeException("Le projet n'existe pas"); } }
public VAll_Auteur GetOne(Utilisateur Entity) { if (Entity != null) { using (Crownfunding_EditionEntities Context = new Crownfunding_EditionEntities()) { return(Context.VAll_Auteur.Find(Entity.Id)); } } else { throw new ArgumentException("Il n'y a pas de type de ce projet"); } }
public void delete(Utilisateur Entity) { if (Entity != null) { using (Crownfunding_EditionEntities Context = new Crownfunding_EditionEntities()) { Context.PSDeleteAuteur(Entity.Id); Context.SaveChanges(); } } else { throw new ArgumentException("La suppression à échoué"); } }
public void insert(NewsLetter Entity) { if (Entity != null) { using (Crownfunding_EditionEntities Context = new Crownfunding_EditionEntities()) { Context.NewsLetter.Add(Entity); Context.SaveChanges(); } } else { throw new ArgumentException("La méthode Inser n'a pas fonctionné"); } }
public VAllUtilisateur GetOne(Utilisateur Entity) { if (Entity != null) { using (Crownfunding_EditionEntities Context = new Crownfunding_EditionEntities()) { VAllUtilisateur MonUtilisateur = Context.VAllUtilisateur.Find(Entity.Id); return(MonUtilisateur); } } else { throw new ArgumentOutOfRangeException("L'utilisateur n'existe pas"); } }
public void Insert(Utilisateur Entity) { if (Entity != null) { using (Crownfunding_EditionEntities Context = new Crownfunding_EditionEntities()) { Context.PSNouveauUtilisateur(Entity.Nom, Entity.Prenom, Entity.Pseudo, Entity.DateDeNaissance, Entity.Email, Entity.Password, Entity.Pays, Entity.Compte_bancaire, Entity.Ad_Rue, Entity.Ad_Ville, Entity.Ad_Code_Post, Entity.Ad_Numero, Entity.NewsLetter, Entity.SecretKey); Context.SaveChanges(); } } else { throw new ArgumentException("L'api Insert à eu un problème"); } }
public void delete(CategorieDeProjet Entity) { if (Entity != null) { using (Crownfunding_EditionEntities Context = new Crownfunding_EditionEntities()) { Context.CategorieDeProjet.Remove(Entity); Context.SaveChanges(); } } else { throw new ArgumentException("La méthode delete n'a pas fonctionné"); } }
public IEnumerable <VUtilNewsLetter> AllEmail() { using (Crownfunding_EditionEntities Context = new Crownfunding_EditionEntities()) { List <VUtilNewsLetter> Selection = Context.VUtilNewsLetter.ToList(); if (Selection.First() != null) { return(Selection); } else { throw new ArgumentOutOfRangeException("La variable selection ne contient aucun Utilisateur"); } } }
public IEnumerable <CategorieDeProjet> GetAll() { using (Crownfunding_EditionEntities Context = new Crownfunding_EditionEntities()) { List <CategorieDeProjet> Selection = Context.CategorieDeProjet.ToList(); if (Selection.First() != null) { return(Selection); } else { throw new ArgumentOutOfRangeException("La variable selection ne contient aucun Utilisateur"); } } }
public CategorieDeProjet Insert(CategorieDeProjet Entity) { if (Entity != null) { using (Crownfunding_EditionEntities Context = new Crownfunding_EditionEntities()) { Context.CategorieDeProjet.Add(Entity); Context.SaveChanges(); return(Context.CategorieDeProjet.LastOrDefault()); } } else { throw new ArgumentNullException("Le projet n'a pas été enregistré"); } }
public void Delete(Utilisateur Entity) { if (Entity != null) { using (Crownfunding_EditionEntities Context = new Crownfunding_EditionEntities()) { Utilisateur Utili = Context.Utilisateur.Find(Entity.Id); Context.Utilisateur.Remove(Utili); Context.SaveChanges(); } } else { throw new ArgumentException("L'api delete n'a pas fonctionné"); } }
public void Delete(Projet Entity) { if (Entity != null) { using (Crownfunding_EditionEntities Context = new Crownfunding_EditionEntities()) { Projet Proj = Context.Projet.Find(Entity.Id); Context.PSPassageProjetHisto(Proj.Id); Context.SaveChanges(); } } else { throw new ArgumentException("La méthode delete n'a pas pu fonctionné"); } }
public IEnumerable <VAll_Auteur> ListeAuteurByType(TypeDeProjet Entity) { using (Crownfunding_EditionEntities Context = new Crownfunding_EditionEntities()) { List <VAll_Auteur> Selection = new List <VAll_Auteur>(); foreach (PSListAuteurByType_Result item in Context.PSListAuteurByType(Entity.Id).ToList()) { Selection.Add(Mappers <PSListAuteurByType_Result, VAll_Auteur> .StoredProcedureToVue(item)); } if (Selection.First() != null) { return(Selection); } else { throw new ArgumentException("Il n'y a pas d'auteur dans cette catégorie"); } } }
public IEnumerable <VAll_Projet> ProjetByAuteur(Utilisateur Entity) { using (Crownfunding_EditionEntities Context = new Crownfunding_EditionEntities()) { List <VAll_Projet> Selection = new List <VAll_Projet>(); foreach (PSListeProjetByAuteur_Result item in Context.PSListeProjetByAuteur(Entity.Id).ToList()) { Selection.Add(Mappers <PSListeProjetByAuteur_Result, VAll_Projet> .StoredProcedureToVue(item)); } if (Selection.First() != null) { return(Selection); } else { throw new ArgumentOutOfRangeException("La variable selection ne contient aucun projet"); } } }
public Projet Insert(Projet Entity, CategorieDeProjet CategoriePrin, CategorieDeProjet CategorieSec, Utilisateur Auteur, TypeDeContrat Contrat, List <Montant> Montants) { // Insertion de projet ce fait par cette méthode uniquement qui appelle la première méthode insert privée pour récupéré le dernier projet inséré afin de récupéré son ID// if (Entity != null) { using (Crownfunding_EditionEntities Context = new Crownfunding_EditionEntities()) { Projet LastInsertProjet = Insert(Entity); DataTable dt = new DataTable(); dt.Columns.AddRange((new DataColumn[2] { new DataColumn("Prix", typeof(int)), new DataColumn("[Description]", typeof(string)) })); foreach (Montant M in Montants) { DataRow LigneMontant = dt.NewRow(); LigneMontant["Prix"] = M.Prix; LigneMontant["[Description]"] = M.Description; dt.Rows.Add(LigneMontant); } ObjectParameter MesMontant = new ObjectParameter("Montant", dt); //Création des parametre sql// ObjectParameter IdProjet = new ObjectParameter("AutoIncrementP", LastInsertProjet.Id); ObjectParameter IdCatPrin = new ObjectParameter("CatPrinc", CategoriePrin.Id); ObjectParameter IdCatSec = new ObjectParameter("CatSec", CategorieSec.Id); ObjectParameter IdUtilisateur = new ObjectParameter("IdUtilisteur", Auteur.Id); ObjectParameter IdContrat = new ObjectParameter("IdContrat", Contrat.Id); Context.Database.ExecuteSqlCommand("Exec PSNouveauProjetInfoSup @AutoIncrementP,@IdUtilisateur,@CatPrinc,@CatSec,@IdContrat,@Montant", IdProjet, IdCatPrin, IdCatSec, IdUtilisateur, IdContrat, MesMontant); return(LastInsertProjet); } } else { throw new ArgumentNullException("Le projet n'a pas été enregistré"); } }