diff --git a/.idea/.idea.ldap-cesi/.idea/dataSources.xml b/.idea/.idea.ldap-cesi/.idea/dataSources.xml
new file mode 100644
index 0000000..62b6f3e
--- /dev/null
+++ b/.idea/.idea.ldap-cesi/.idea/dataSources.xml
@@ -0,0 +1,18 @@
+
+
+
+
+ postgresql
+ true
+ org.postgresql.Driver
+ jdbc:postgresql://192.168.1.196:5432/ldap
+
+
+
+
+
+
+ $ProjectFileDir$
+
+
+
\ No newline at end of file
diff --git a/ldap-cesi/Configurations/Conf.cs b/ldap-cesi/Configurations/Conf.cs
new file mode 100644
index 0000000..d1dbb77
--- /dev/null
+++ b/ldap-cesi/Configurations/Conf.cs
@@ -0,0 +1,19 @@
+using ldap_cesi.Context;
+using ldap_cesi.Entities;
+using Microsoft.EntityFrameworkCore;
+
+namespace ldap_cesi.Configurations;
+
+public static class Conf
+{
+ public static void BuildConf(this WebApplicationBuilder builder)
+ {
+ builder.AddEFCoreConfiguration();
+ }
+
+ public static void AddEFCoreConfiguration(this WebApplicationBuilder builder)
+ {
+ string connectionString = builder.Configuration.GetConnectionString("DefaultConnection");
+ builder.Services.AddDbContext(options => options.UseNpgsql(connectionString));
+ }
+}
\ No newline at end of file
diff --git a/ldap-cesi/Context/PgContext.cs b/ldap-cesi/Context/PgContext.cs
new file mode 100644
index 0000000..778e575
--- /dev/null
+++ b/ldap-cesi/Context/PgContext.cs
@@ -0,0 +1,135 @@
+using System;
+using System.Collections.Generic;
+using ldap_cesi.Entities;
+using Microsoft.EntityFrameworkCore;
+
+namespace ldap_cesi.Context;
+
+public partial class PgContext : DbContext
+{
+ public PgContext()
+ {
+ }
+
+ public PgContext(DbContextOptions options)
+ : base(options)
+ {
+ }
+
+ public virtual DbSet Roles { get; set; }
+
+ public virtual DbSet Salaries { get; set; }
+
+ public virtual DbSet Services { get; set; }
+
+ public virtual DbSet Sites { get; set; }
+
+ public virtual DbSet Utilisateurs { get; set; }
+
+ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
+#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see https://go.microsoft.com/fwlink/?LinkId=723263.
+ => optionsBuilder.UseNpgsql("Host=192.168.1.196;Database=ldap;Username=postgres;Password=pimer0-buzz");
+
+ protected override void OnModelCreating(ModelBuilder modelBuilder)
+ {
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(e => e.Id).HasName("role_pk");
+
+ entity.ToTable("role");
+
+ entity.Property(e => e.Id).HasColumnName("id");
+ entity.Property(e => e.Nom)
+ .HasMaxLength(50)
+ .HasColumnName("nom");
+ });
+
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(e => e.Id).HasName("salarie_pk");
+
+ entity.ToTable("salarie");
+
+ entity.Property(e => e.Id).HasColumnName("id");
+ entity.Property(e => e.Email)
+ .HasMaxLength(50)
+ .HasColumnName("email");
+ entity.Property(e => e.IdService).HasColumnName("id_service");
+ entity.Property(e => e.IdSite).HasColumnName("id_site");
+ entity.Property(e => e.Nom)
+ .HasMaxLength(50)
+ .HasColumnName("nom");
+ entity.Property(e => e.Prenom)
+ .HasMaxLength(50)
+ .HasColumnName("prenom");
+ entity.Property(e => e.TelephoneFixe)
+ .HasMaxLength(50)
+ .HasColumnName("telephone_fixe");
+ entity.Property(e => e.TelephonePortable)
+ .HasMaxLength(50)
+ .HasColumnName("telephone_portable");
+
+ entity.HasOne(d => d.IdServiceNavigation).WithMany(p => p.Salaries)
+ .HasForeignKey(d => d.IdService)
+ .OnDelete(DeleteBehavior.ClientSetNull)
+ .HasConstraintName("salarie_service0_fk");
+
+ entity.HasOne(d => d.IdSiteNavigation).WithMany(p => p.Salaries)
+ .HasForeignKey(d => d.IdSite)
+ .OnDelete(DeleteBehavior.ClientSetNull)
+ .HasConstraintName("salarie_site_fk");
+ });
+
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(e => e.Id).HasName("service_pk");
+
+ entity.ToTable("service");
+
+ entity.Property(e => e.Id).HasColumnName("id");
+ entity.Property(e => e.Nom)
+ .HasMaxLength(50)
+ .HasColumnName("nom");
+ });
+
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(e => e.Id).HasName("site_pk");
+
+ entity.ToTable("site");
+
+ entity.Property(e => e.Id).HasColumnName("id");
+ entity.Property(e => e.Ville)
+ .HasMaxLength(150)
+ .HasColumnName("ville");
+ });
+
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(e => e.Id).HasName("utilisateur_pk");
+
+ entity.ToTable("utilisateur");
+
+ entity.Property(e => e.Id).HasColumnName("id");
+ entity.Property(e => e.IdRole).HasColumnName("id_role");
+ entity.Property(e => e.MotDePasse)
+ .HasMaxLength(50)
+ .HasColumnName("mot_de_passe");
+ entity.Property(e => e.Nom)
+ .HasMaxLength(50)
+ .HasColumnName("nom");
+ entity.Property(e => e.Prenom)
+ .HasMaxLength(50)
+ .HasColumnName("prenom");
+
+ entity.HasOne(d => d.IdRoleNavigation).WithMany(p => p.Utilisateurs)
+ .HasForeignKey(d => d.IdRole)
+ .OnDelete(DeleteBehavior.ClientSetNull)
+ .HasConstraintName("utilisateur_role_fk");
+ });
+
+ OnModelCreatingPartial(modelBuilder);
+ }
+
+ partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
+}
diff --git a/ldap-cesi/Entities/Role.cs b/ldap-cesi/Entities/Role.cs
new file mode 100644
index 0000000..bd74754
--- /dev/null
+++ b/ldap-cesi/Entities/Role.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+
+namespace ldap_cesi.Entities;
+
+public partial class Role
+{
+ public int Id { get; set; }
+
+ public string Nom { get; set; } = null!;
+
+ public virtual ICollection Utilisateurs { get; set; } = new List();
+}
diff --git a/ldap-cesi/Entities/Salarie.cs b/ldap-cesi/Entities/Salarie.cs
new file mode 100644
index 0000000..9ccc76a
--- /dev/null
+++ b/ldap-cesi/Entities/Salarie.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+
+namespace ldap_cesi.Entities;
+
+public partial class Salarie
+{
+ public int Id { get; set; }
+
+ public string Nom { get; set; } = null!;
+
+ public string Prenom { get; set; } = null!;
+
+ public string TelephoneFixe { get; set; } = null!;
+
+ public string TelephonePortable { get; set; } = null!;
+
+ public string Email { get; set; } = null!;
+
+ public int IdSite { get; set; }
+
+ public int IdService { get; set; }
+
+ public virtual Service IdServiceNavigation { get; set; } = null!;
+
+ public virtual Site IdSiteNavigation { get; set; } = null!;
+}
diff --git a/ldap-cesi/Entities/Service.cs b/ldap-cesi/Entities/Service.cs
new file mode 100644
index 0000000..912f597
--- /dev/null
+++ b/ldap-cesi/Entities/Service.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+
+namespace ldap_cesi.Entities;
+
+public partial class Service
+{
+ public int Id { get; set; }
+
+ public string Nom { get; set; } = null!;
+
+ public virtual ICollection Salaries { get; set; } = new List();
+}
diff --git a/ldap-cesi/Entities/Site.cs b/ldap-cesi/Entities/Site.cs
new file mode 100644
index 0000000..40c7f26
--- /dev/null
+++ b/ldap-cesi/Entities/Site.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+
+namespace ldap_cesi.Entities;
+
+public partial class Site
+{
+ public int Id { get; set; }
+
+ public string? Ville { get; set; }
+
+ public virtual ICollection Salaries { get; set; } = new List();
+}
diff --git a/ldap-cesi/Entities/Utilisateur.cs b/ldap-cesi/Entities/Utilisateur.cs
new file mode 100644
index 0000000..8f2223b
--- /dev/null
+++ b/ldap-cesi/Entities/Utilisateur.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+
+namespace ldap_cesi.Entities;
+
+public partial class Utilisateur
+{
+ public int Id { get; set; }
+
+ public string? Nom { get; set; }
+
+ public string? Prenom { get; set; }
+
+ public string? MotDePasse { get; set; }
+
+ public int IdRole { get; set; }
+
+ public virtual Role IdRoleNavigation { get; set; } = null!;
+}
diff --git a/ldap-cesi/Program.cs b/ldap-cesi/Program.cs
index d5e0ef3..5881c4b 100644
--- a/ldap-cesi/Program.cs
+++ b/ldap-cesi/Program.cs
@@ -1,7 +1,8 @@
+using ldap_cesi.Configurations;
+
var builder = WebApplication.CreateBuilder(args);
-// Add services to the container.
-// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
+builder.BuildConf();
builder.Services.AddOpenApi();
var app = builder.Build();
@@ -14,28 +15,4 @@ if (app.Environment.IsDevelopment())
app.UseHttpsRedirection();
-var summaries = new[]
-{
- "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
-};
-
-app.MapGet("/weatherforecast", () =>
- {
- var forecast = Enumerable.Range(1, 5).Select(index =>
- new WeatherForecast
- (
- DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
- Random.Shared.Next(-20, 55),
- summaries[Random.Shared.Next(summaries.Length)]
- ))
- .ToArray();
- return forecast;
- })
- .WithName("GetWeatherForecast");
-
app.Run();
-
-record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)
-{
- public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
-}
\ No newline at end of file
diff --git a/ldap-cesi/ldap-cesi.csproj b/ldap-cesi/ldap-cesi.csproj
index ab3c826..e7d67ee 100644
--- a/ldap-cesi/ldap-cesi.csproj
+++ b/ldap-cesi/ldap-cesi.csproj
@@ -8,7 +8,24 @@
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
+
+