- Api v1.0 #20
18
.idea/.idea.ldap-cesi/.idea/dataSources.xml
generated
Normal file
18
.idea/.idea.ldap-cesi/.idea/dataSources.xml
generated
Normal file
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||
<data-source source="LOCAL" name="ldap@192.168.1.196" uuid="4416cc9a-9c84-4a37-8ec1-70323890f91e">
|
||||
<driver-ref>postgresql</driver-ref>
|
||||
<synchronize>true</synchronize>
|
||||
<jdbc-driver>org.postgresql.Driver</jdbc-driver>
|
||||
<jdbc-url>jdbc:postgresql://192.168.1.196:5432/ldap</jdbc-url>
|
||||
<jdbc-additional-properties>
|
||||
<property name="com.intellij.clouds.kubernetes.db.host.port" />
|
||||
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
|
||||
<property name="com.intellij.clouds.kubernetes.db.resource.type" value="Deployment" />
|
||||
<property name="com.intellij.clouds.kubernetes.db.container.port" />
|
||||
</jdbc-additional-properties>
|
||||
<working-dir>$ProjectFileDir$</working-dir>
|
||||
</data-source>
|
||||
</component>
|
||||
</project>
|
19
ldap-cesi/Configurations/Conf.cs
Normal file
19
ldap-cesi/Configurations/Conf.cs
Normal file
@ -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<PgContext>(options => options.UseNpgsql(connectionString));
|
||||
}
|
||||
}
|
135
ldap-cesi/Context/PgContext.cs
Normal file
135
ldap-cesi/Context/PgContext.cs
Normal file
@ -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<PgContext> options)
|
||||
: base(options)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual DbSet<Role> Roles { get; set; }
|
||||
|
||||
public virtual DbSet<Salarie> Salaries { get; set; }
|
||||
|
||||
public virtual DbSet<Service> Services { get; set; }
|
||||
|
||||
public virtual DbSet<Site> Sites { get; set; }
|
||||
|
||||
public virtual DbSet<Utilisateur> 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<Role>(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<Salarie>(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<Service>(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<Site>(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<Utilisateur>(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);
|
||||
}
|
13
ldap-cesi/Entities/Role.cs
Normal file
13
ldap-cesi/Entities/Role.cs
Normal file
@ -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<Utilisateur> Utilisateurs { get; set; } = new List<Utilisateur>();
|
||||
}
|
27
ldap-cesi/Entities/Salarie.cs
Normal file
27
ldap-cesi/Entities/Salarie.cs
Normal file
@ -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!;
|
||||
}
|
13
ldap-cesi/Entities/Service.cs
Normal file
13
ldap-cesi/Entities/Service.cs
Normal file
@ -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<Salarie> Salaries { get; set; } = new List<Salarie>();
|
||||
}
|
13
ldap-cesi/Entities/Site.cs
Normal file
13
ldap-cesi/Entities/Site.cs
Normal file
@ -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<Salarie> Salaries { get; set; } = new List<Salarie>();
|
||||
}
|
19
ldap-cesi/Entities/Utilisateur.cs
Normal file
19
ldap-cesi/Entities/Utilisateur.cs
Normal file
@ -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!;
|
||||
}
|
@ -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);
|
||||
}
|
@ -8,7 +8,28 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoMapper" Version="14.0.0" />
|
||||
<PackageReference Include="BCrypt" Version="1.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.2"/>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.2">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="10.0.0-preview.1.25081.1">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.3" />
|
||||
<PackageReference Include="OpenAI" Version="2.2.0-beta.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Controllers\" />
|
||||
<Folder Include="Entities\" />
|
||||
<Folder Include="Mapper\" />
|
||||
<Folder Include="Repository\" />
|
||||
<Folder Include="Services\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
Loading…
x
Reference in New Issue
Block a user