Ajout du niveau d'experience

This commit is contained in:
2026-06-11 11:06:31 +02:00
parent 35c99928ad
commit 5d16138ed8
16 changed files with 2270 additions and 26 deletions
@@ -3,4 +3,5 @@ namespace PyroFetes.DTO.ExperienceLevel.Request;
public class CreateExperienceLevelDto
{
public string? Label { get; set; }
public int? StaffId { get; set; }
}
@@ -4,4 +4,6 @@ public class GetExperienceLevelDto
{
public int Id { get; set; }
public string? Label { get; set; }
public int? StaffId { get; set; }
}
@@ -4,4 +4,5 @@ public class CreateHistoryOfApprovalDto
{
public DateOnly DeliveryDate { get; set; }
public DateOnly ExpirationDate { get; set; }
public int StaffId { get; set; }
}
@@ -5,4 +5,6 @@ public class GetHistoryOfApprovalDto
public int Id { get; set; }
public DateOnly DeliveryDate { get; set; }
public DateOnly ExpirationDate { get; set; }
public int StaffId { get; set; }
}
@@ -6,4 +6,6 @@ public class GetProviderDto
public decimal Price { get; set; }
public int ProviderTypeId { get; set; }
public string? ProviderType { get; set; }
}
@@ -9,4 +9,6 @@ public class GetStaffDto
public string? Email { get; set; }
public string? F4T2NumberApproval { get; set; }
public DateOnly F4T2ExpirationDate { get; set; }
public string? ExperienceLevel { get; set; }
}
@@ -1,5 +1,6 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.ExperienceLevel.Response;
using PyroFetes.DTO.ExperienceLevel.Request;
@@ -15,9 +16,20 @@ public class CreateExperienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext
public override async Task HandleAsync(CreateExperienceLevelDto req, CancellationToken ct)
{
Models.Staff? databaseStaff = await pyroFetesDbContext.Staffs.SingleOrDefaultAsync(x => x.Id == req.StaffId, cancellationToken: ct);
if (databaseStaff == null)
{
await Send.NotFoundAsync(ct);
Console.WriteLine("Customer Type not found");
return;
}
Models.ExperienceLevel experienceLevel = new()
{
Label = req.Label
Label = req.Label,
StaffId = databaseStaff.Id,
};
pyroFetesDbContext.Add(experienceLevel);
await pyroFetesDbContext.SaveChangesAsync(ct);
@@ -26,6 +38,7 @@ public class CreateExperienceLevelEndpoint(PyroFetesDbContext pyroFetesDbContext
{
Id = experienceLevel.Id,
Label = experienceLevel.Label,
StaffId = experienceLevel.StaffId
};
await Send.OkAsync(response, ct);
@@ -1,4 +1,5 @@
using FastEndpoints;
using Microsoft.EntityFrameworkCore;
using PyroFetes.DTO.HistoryOfApproval.Request;
using PyroFetes.DTO.HistoryOfApproval.Response;
@@ -15,10 +16,21 @@ public class CreateHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbConte
public override async Task HandleAsync(CreateHistoryOfApprovalDto req, CancellationToken ct)
{
Models.Staff? databaseStaff = await pyroFetesDbContext.Staffs.SingleOrDefaultAsync(x => x.Id == req.StaffId, cancellationToken: ct);
if (databaseStaff == null)
{
await Send.NotFoundAsync(ct);
Console.WriteLine("Customer Type not found");
return;
}
Models.HistoryOfApproval historyOfApproval = new()
{
DeliveryDate = req.DeliveryDate,
ExpirationDate = req.ExpirationDate
ExpirationDate = req.ExpirationDate,
StaffId = databaseStaff.Id,
};
pyroFetesDbContext.Add(historyOfApproval);
await pyroFetesDbContext.SaveChangesAsync(ct);
@@ -27,7 +39,8 @@ public class CreateHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbConte
{
Id = historyOfApproval.Id,
DeliveryDate = historyOfApproval.DeliveryDate,
ExpirationDate = historyOfApproval.ExpirationDate
ExpirationDate = historyOfApproval.ExpirationDate,
StaffId = historyOfApproval.StaffId,
};
await Send.OkAsync(response, ct);
@@ -19,6 +19,7 @@ public class GetAllHistoryOfApprovalEndpoint(PyroFetesDbContext pyroFetesDbConte
Id = x.Id,
DeliveryDate = x.DeliveryDate,
ExpirationDate = x.ExpirationDate,
StaffId = x.StaffId,
}).ToListAsync(ct);
await Send.OkAsync(historyOfApprovals, ct);
@@ -14,11 +14,12 @@ public class GetAllProvidersEndpoint(PyroFetesDbContext pyroFetesDbContext) : En
public override async Task HandleAsync(CancellationToken ct)
{
List<GetProviderDto> provider= await pyroFetesDbContext.ServiceProviders.Select(x => new GetProviderDto()
List<GetProviderDto> provider= await pyroFetesDbContext.ServiceProviders.Include(x => x.ProviderType).Select(x => new GetProviderDto()
{
Id = x.Id,
Price = x.Price,
ProviderTypeId = x.ProviderTypeId,
ProviderType = x.ProviderType.Label,
}).ToListAsync(ct);
await Send.OkAsync(provider, ct);
@@ -7,25 +7,28 @@ namespace PyroFetes.Endpoints.Staff;
public class GetAllStaffsEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest<List<GetStaffDto>>
{
public override void Configure()
{
Get ("/staffs");
{
Get("/staffs");
AllowAnonymous();
}
public override async Task HandleAsync(CancellationToken ct)
{
List<GetStaffDto> staff = await pyroFetesDbContext.Staffs.Select(x => new GetStaffDto()
{
Id = x.Id,
FirstName = x.FirstName,
LastName = x.LastName,
Profession = x.Profession,
Email = x.Email,
F4T2NumberApproval = x.F4T2NumberApproval,
F4T2ExpirationDate = x.F4T2ExpirationDate,
}).ToListAsync(ct);
List<GetStaffDto> staff = await pyroFetesDbContext.Staffs
.Include(x => x.ExperienceLevel)
.Select(x => new GetStaffDto()
{
Id = x.Id,
FirstName = x.FirstName,
LastName = x.LastName,
Profession = x.Profession,
Email = x.Email,
F4T2NumberApproval = x.F4T2NumberApproval,
F4T2ExpirationDate = x.F4T2ExpirationDate,
ExperienceLevel = x.ExperienceLevel.Label
}).ToListAsync(ct);
await Send.OkAsync(staff, ct);
}
}
File diff suppressed because it is too large Load Diff
+246
View File
@@ -0,0 +1,246 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PyroFetes.Migrations
{
/// <inheritdoc />
public partial class HOA : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_ContactServiceProvider_Providers_ServiceProviderId",
table: "ContactServiceProvider");
migrationBuilder.DropForeignKey(
name: "FK_Contract_Providers_ServiceProviderId",
table: "Contract");
migrationBuilder.DropForeignKey(
name: "FK_ProviderContacts_Providers_ProviderId",
table: "ProviderContacts");
migrationBuilder.DropForeignKey(
name: "FK_Providers_ProviderTypes_ProviderTypeId",
table: "Providers");
migrationBuilder.DropIndex(
name: "IX_ExperienceLevels_StaffId",
table: "ExperienceLevels");
migrationBuilder.DropPrimaryKey(
name: "PK_Providers",
table: "Providers");
migrationBuilder.RenameTable(
name: "Providers",
newName: "ServiceProviders");
migrationBuilder.RenameIndex(
name: "IX_Providers_ProviderTypeId",
table: "ServiceProviders",
newName: "IX_ServiceProviders_ProviderTypeId");
migrationBuilder.AddColumn<int>(
name: "StaffId",
table: "HistoryOfApprovals",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AlterColumn<string>(
name: "Meeting",
table: "Communications",
type: "nvarchar(300)",
maxLength: 300,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(300)",
oldMaxLength: 300);
migrationBuilder.AlterColumn<string>(
name: "Email",
table: "Communications",
type: "nvarchar(100)",
maxLength: 100,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(100)",
oldMaxLength: 100);
migrationBuilder.AlterColumn<string>(
name: "Calling",
table: "Communications",
type: "nvarchar(100)",
maxLength: 100,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(100)",
oldMaxLength: 100);
migrationBuilder.AddPrimaryKey(
name: "PK_ServiceProviders",
table: "ServiceProviders",
column: "Id");
migrationBuilder.CreateIndex(
name: "IX_ExperienceLevels_StaffId",
table: "ExperienceLevels",
column: "StaffId",
unique: true);
migrationBuilder.AddForeignKey(
name: "FK_ContactServiceProvider_ServiceProviders_ServiceProviderId",
table: "ContactServiceProvider",
column: "ServiceProviderId",
principalTable: "ServiceProviders",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Contract_ServiceProviders_ServiceProviderId",
table: "Contract",
column: "ServiceProviderId",
principalTable: "ServiceProviders",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_ProviderContacts_ServiceProviders_ProviderId",
table: "ProviderContacts",
column: "ProviderId",
principalTable: "ServiceProviders",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_ServiceProviders_ProviderTypes_ProviderTypeId",
table: "ServiceProviders",
column: "ProviderTypeId",
principalTable: "ProviderTypes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_ContactServiceProvider_ServiceProviders_ServiceProviderId",
table: "ContactServiceProvider");
migrationBuilder.DropForeignKey(
name: "FK_Contract_ServiceProviders_ServiceProviderId",
table: "Contract");
migrationBuilder.DropForeignKey(
name: "FK_ProviderContacts_ServiceProviders_ProviderId",
table: "ProviderContacts");
migrationBuilder.DropForeignKey(
name: "FK_ServiceProviders_ProviderTypes_ProviderTypeId",
table: "ServiceProviders");
migrationBuilder.DropIndex(
name: "IX_ExperienceLevels_StaffId",
table: "ExperienceLevels");
migrationBuilder.DropPrimaryKey(
name: "PK_ServiceProviders",
table: "ServiceProviders");
migrationBuilder.DropColumn(
name: "StaffId",
table: "HistoryOfApprovals");
migrationBuilder.RenameTable(
name: "ServiceProviders",
newName: "Providers");
migrationBuilder.RenameIndex(
name: "IX_ServiceProviders_ProviderTypeId",
table: "Providers",
newName: "IX_Providers_ProviderTypeId");
migrationBuilder.AlterColumn<string>(
name: "Meeting",
table: "Communications",
type: "nvarchar(300)",
maxLength: 300,
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "nvarchar(300)",
oldMaxLength: 300,
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Email",
table: "Communications",
type: "nvarchar(100)",
maxLength: 100,
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "nvarchar(100)",
oldMaxLength: 100,
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Calling",
table: "Communications",
type: "nvarchar(100)",
maxLength: 100,
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "nvarchar(100)",
oldMaxLength: 100,
oldNullable: true);
migrationBuilder.AddPrimaryKey(
name: "PK_Providers",
table: "Providers",
column: "Id");
migrationBuilder.CreateIndex(
name: "IX_ExperienceLevels_StaffId",
table: "ExperienceLevels",
column: "StaffId");
migrationBuilder.AddForeignKey(
name: "FK_ContactServiceProvider_Providers_ServiceProviderId",
table: "ContactServiceProvider",
column: "ServiceProviderId",
principalTable: "Providers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Contract_Providers_ServiceProviderId",
table: "Contract",
column: "ServiceProviderId",
principalTable: "Providers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_ProviderContacts_Providers_ProviderId",
table: "ProviderContacts",
column: "ProviderId",
principalTable: "Providers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Providers_ProviderTypes_ProviderTypeId",
table: "Providers",
column: "ProviderTypeId",
principalTable: "ProviderTypes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}
@@ -136,7 +136,6 @@ namespace PyroFetes.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Calling")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
@@ -144,12 +143,10 @@ namespace PyroFetes.Migrations
.HasColumnType("int");
b.Property<string>("Email")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.Property<string>("Meeting")
.IsRequired()
.HasMaxLength(300)
.HasColumnType("nvarchar(300)");
@@ -377,7 +374,8 @@ namespace PyroFetes.Migrations
b.HasKey("Id");
b.HasIndex("StaffId");
b.HasIndex("StaffId")
.IsUnique();
b.ToTable("ExperienceLevels");
});
@@ -396,6 +394,9 @@ namespace PyroFetes.Migrations
b.Property<DateOnly>("ExpirationDate")
.HasColumnType("date");
b.Property<int>("StaffId")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("HistoryOfApprovals");
@@ -781,7 +782,7 @@ namespace PyroFetes.Migrations
b.HasIndex("ProviderTypeId");
b.ToTable("Providers");
b.ToTable("ServiceProviders");
});
modelBuilder.Entity("PyroFetes.Models.Setting", b =>
@@ -1333,8 +1334,8 @@ namespace PyroFetes.Migrations
modelBuilder.Entity("PyroFetes.Models.ExperienceLevel", b =>
{
b.HasOne("PyroFetes.Models.Staff", "Staff")
.WithMany("ExperienceLevels")
.HasForeignKey("StaffId")
.WithOne("ExperienceLevel")
.HasForeignKey("PyroFetes.Models.ExperienceLevel", "StaffId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@@ -1911,7 +1912,8 @@ namespace PyroFetes.Migrations
modelBuilder.Entity("PyroFetes.Models.Staff", b =>
{
b.Navigation("ExperienceLevels");
b.Navigation("ExperienceLevel")
.IsRequired();
b.Navigation("ShowStaffs");
+2
View File
@@ -8,5 +8,7 @@ public class HistoryOfApproval
[Required] public DateOnly DeliveryDate { get; set; }
[Required] public DateOnly ExpirationDate { get; set; }
public int StaffId { get; set; }
public List<StaffHistoryOfApproval>? StaffHistoryOfApprovals { get; set; }
}
+1 -1
View File
@@ -13,7 +13,7 @@ public class Staff
[Required] public DateOnly F4T2ExpirationDate { get; set; }
public List<ShowStaff>? ShowStaffs { get; set; }
public List<ExperienceLevel>? ExperienceLevels { get; set; }
public ExperienceLevel ExperienceLevel { get; set; }
public List<StaffAvailability>? StaffAvailabilities { get; set; }
public List<StaffHistoryOfApproval>? StaffHistoryOfApprovals { get; set; }
public List<StaffContact>? StaffContacts { get; set; }