using EPAServeur.Models.EP; using EPAServeur.Models.Formation; using EPAServeur.Models.Notes; using EPAServeur.Models.SaisieChamp; using Microsoft.EntityFrameworkCore; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; namespace EPAServeur.Context { public class EpContext : DbContext { //EP public DbSet AugmentationSalaire { get; set; } public DbSet Autorisation { get; set; } public DbSet ChoixTypeEntretien { get; set; } public DbSet Document { get; set; } public DbSet Engagement { get; set; } public DbSet Ep { get; set; } public DbSet Objectif { get; set; } public DbSet ObjectifPrecedent { get; set; } public DbSet RdvEntretien { get; set; } public DbSet TypeEntretien { get; set; } //Formation public DbSet DemandeFormation { get; set; } public DbSet Formation { get; set; } public DbSet ModeFormation { get; set; } public DbSet OrigineDemandeFormation { get; set; } public DbSet OrigineFormation { get; set; } public DbSet ParticipationFormation { get; set; } public DbSet StatutFormation { get; set; } public DbSet Theme { get; set; } public DbSet TypeFormation { get; set; } //Note public DbSet Note { get; set; } //SaisieChamp public DbSet Champ { get; set; } public DbSet Saisie { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseMySQL("server=localhost;database=server_ep;user=root;password=root");//PENSER A METTRE DANS UN FICHIER DE CONFIG } protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); //EP modelBuilder.Entity(entity => { entity.HasKey(e => e.Id); entity.Property(e => e.Id).ValueGeneratedOnAdd(); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id); entity.Property(e => e.Id).ValueGeneratedOnAdd(); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id); entity.Property(e => e.Id).ValueGeneratedOnAdd(); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id); entity.Property(e => e.Id).ValueGeneratedOnAdd(); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id); entity.HasOne(e => e.AugmentationSalaire).WithOne(a => a.Ep).HasForeignKey(a => a.EpId); entity.HasOne(e => e.Autorisation).WithOne( a => a.Ep).HasForeignKey(a => a.EpId); entity.HasMany(e => e.ChoixTypeEntretien).WithOne(c => c.Ep); entity.HasOne(e => e.Delegation).WithOne(d => d.Ep).HasForeignKey(d => d.EpId); entity.HasMany(e => e.DemandesFormation).WithOne(d => d.Ep); entity.HasMany(e => e.Documents).WithOne(d => d.Ep); entity.HasMany(e => e.Engagements).WithOne(e => e.Ep); entity.HasMany(e => e.Objectifs).WithOne(o => o.Ep); entity.HasMany(e => e.ObjectifsPrecedents).WithOne(o => o.Ep); entity.HasMany(e => e.Participants).WithOne(p => p.Ep); entity.HasOne(e => e.RdvEntretien).WithOne(r => r.EpChoixFinal).HasForeignKey(r => r.EpId); entity.HasMany(e => e.PropositionsRDV).WithOne(r => r.EpProposition); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id); entity.Property(e => e.Id).ValueGeneratedOnAdd(); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id); entity.Property(e => e.Id).ValueGeneratedOnAdd(); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id); entity.Property(e => e.Id).ValueGeneratedOnAdd(); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id); entity.HasIndex(e => e.Libelle).IsUnique(); }); //Formation modelBuilder.Entity(entity => { entity.HasKey(e => e.Id); entity.Property(e => e.Id).ValueGeneratedOnAdd(); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id); entity.Property(e => e.Id).ValueGeneratedOnAdd(); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id); entity.Property(e => e.Id).ValueGeneratedOnAdd(); entity.HasIndex(e => e.Libelle).IsUnique(); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id); entity.Property(e => e.Id).ValueGeneratedOnAdd(); entity.HasIndex(e => e.Libelle).IsUnique(); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id); entity.Property(e => e.Id).ValueGeneratedOnAdd(); entity.HasIndex(e => e.Libelle).IsUnique(); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id); entity.Property(e => e.Id).ValueGeneratedOnAdd(); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id); entity.Property(e => e.Id).ValueGeneratedOnAdd(); entity.HasIndex(e => e.Libelle).IsUnique(); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id); entity.Property(e => e.Id).ValueGeneratedOnAdd(); entity.HasIndex(e => e.Libelle).IsUnique(); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id); entity.Property(e => e.Id).ValueGeneratedOnAdd(); entity.HasIndex(e => e.Libelle).IsUnique(); }); //Notes modelBuilder.Entity(entity => { entity.HasKey(e => e.Id); entity.Property(e => e.Id).ValueGeneratedOnAdd(); }); //SaisieChamp modelBuilder.Entity(entity => { entity.HasKey(e => e.Id); entity.Property(e => e.Id).ValueGeneratedOnAdd(); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id); entity.Property(e => e.Id).ValueGeneratedOnAdd(); }); } public void AjoutTheme() //Les thèmes pourront être ajoutés et conservés { Theme management, securite, developpement, gestionprojet; management = new Theme { Libelle = "Management" }; this.Theme.Add(management); securite = new Theme { Libelle = "Sécurité" }; this.Theme.Add(securite); developpement = new Theme { Libelle = "Développement" }; this.Theme.Add(developpement); gestionprojet = new Theme { Libelle = "Gestion de projet" }; this.Theme.Add(gestionprojet); this.SaveChanges(); } /*Les informations ajou * */ public void AjoutInformationsDeBase() //Les statuts pourront être ajoutés et conservés { //StatutFormation StatutFormation s; s = new StatutFormation { Libelle = "Planifiée" }; this.StatutFormation.Add(s); s = new StatutFormation { Libelle = "Replanifié" }; this.StatutFormation.Add(s); s = new StatutFormation { Libelle = "Réalisée" }; this.StatutFormation.Add(s); s = new StatutFormation { Libelle = "Annulée" }; this.StatutFormation.Add(s); //ModeFormation ModeFormation m; m = new ModeFormation { Libelle = "Externe" }; this.ModeFormation.Add(m); m = new ModeFormation { Libelle = "Interne" }; this.ModeFormation.Add(m); m = new ModeFormation { Libelle = "Présentiel" }; this.ModeFormation.Add(m); m = new ModeFormation { Libelle = "E-learning" }; this.ModeFormation.Add(m); //TypeFormation TypeFormation type; type = new TypeFormation { Libelle = "Externe" }; this.TypeFormation.Add(type); type = new TypeFormation { Libelle = "Interne" }; this.TypeFormation.Add(type); type = new TypeFormation { Libelle = "E-learning" }; this.TypeFormation.Add(type); type = new TypeFormation { Libelle = "Academy by Apside" }; this.TypeFormation.Add(type); //OrigineFormation OrigineFormation of; of = new OrigineFormation { Libelle = "Demande collaborateur" }; this.OrigineFormation.Add(of); of = new OrigineFormation { Libelle = "Exigence client" }; this.OrigineFormation.Add(of); of = new OrigineFormation { Libelle = "Exigence Apside" }; this.OrigineFormation.Add(of); of = new OrigineFormation { Libelle = "Formation réglementaire" }; this.OrigineFormation.Add(of); //OrigineDemandeFormation OrigineDemandeFormation o; o = new OrigineDemandeFormation { Libelle = "Demande collaborateur" }; this.OrigineDemandeFormation.Add(o); o = new OrigineDemandeFormation { Libelle = "Demande EP" }; this.OrigineDemandeFormation.Add(o); o = new OrigineDemandeFormation { Libelle = "Exigence Client" }; this.OrigineDemandeFormation.Add(o); o = new OrigineDemandeFormation { Libelle = "Formation réglementaire" }; this.OrigineDemandeFormation.Add(o); o = new OrigineDemandeFormation { Libelle = "Demande Apside" }; this.OrigineDemandeFormation.Add(o); //TypeEntretien TypeEntretien t; t = new TypeEntretien { Libelle = "Sur site" }; this.TypeEntretien.Add(t); t = new TypeEntretien { Libelle = "Chez le client" }; this.TypeEntretien.Add(t); t = new TypeEntretien { Libelle = "Visioconférence" }; this.TypeEntretien.Add(t); t = new TypeEntretien { Libelle = "Téléphonique" }; this.TypeEntretien.Add(t); this.SaveChanges(); } } }