Esempio n. 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é");
     }
 }
Esempio n. 2
0
 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");
     }
 }
Esempio n. 3
0
 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é");
     }
 }
Esempio n. 4
0
 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é");
     }
 }
Esempio n. 5
0
 public IEnumerable <VAll_Projet> GetAllByCategorie(CategorieDeProjet Entity)
 {
     using (Crownfunding_EditionEntities Context = new Crownfunding_EditionEntities())
     {
         List <VAll_Projet> Selection = new List <VAll_Projet>();
         foreach (PSListAuteurByCategoryPrincAndSec_Result item in Context.PSListAuteurByCategoryPrincAndSec(Entity.Id).ToList())
         {
             Selection.Add(Mappers <PSListAuteurByCategoryPrincAndSec_Result, VAll_Projet> .StoredProcedureToVue(item));
         }
         if (Selection.First() != null)
         {
             return(Selection);
         }
         else
         {
             throw new ArgumentOutOfRangeException("La variable selection ne contient aucun projet");
         }
     }
 }
 public IEnumerable <VAll_Auteur> ListeAuteurByCat(CategorieDeProjet Entity)
 {
     using (Crownfunding_EditionEntities Context = new Crownfunding_EditionEntities())
     {
         List <VAll_Auteur> Selection = new List <VAll_Auteur>();
         foreach (PSListAuteurByCategoryPrincAndSec_Result item in Context.PSListAuteurByCategoryPrincAndSec(Entity.Id).ToList())
         {
             Selection.Add(Mappers <PSListAuteurByCategoryPrincAndSec_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");
         }
     }
 }
Esempio n. 7
0
        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é");
            }
        }