finalisation des endpoints
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
namespace PF3.DTO.Show.Request;
|
namespace PyroFetes.DTO.Show.Request;
|
||||||
|
|
||||||
public class CreateShowDto
|
public class CreateShowDto
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace PF3.DTO.Show.Request;
|
namespace PyroFetes.DTO.Show.Request;
|
||||||
|
|
||||||
public class IdShowDto
|
public class IdShowDto
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace PF3.DTO.Show.Request;
|
namespace PyroFetes.DTO.Show.Request;
|
||||||
|
|
||||||
public class UpdateShowDto
|
public class UpdateShowDto
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace PF3.DTO.Show.Response;
|
namespace PyroFetes.DTO.Show.Response;
|
||||||
|
|
||||||
public class ReadShowDto
|
public class ReadShowDto
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace PF3.DTO.SoundCategory.Request;
|
namespace PyroFetes.DTO.Sound.Request;
|
||||||
|
|
||||||
public class CreateSoundDto
|
public class CreateSoundDto
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace PF3.DTO.SoundCategory.Request;
|
namespace PyroFetes.DTO.Sound.Request;
|
||||||
|
|
||||||
public class IdSoundto
|
public class IdSoundto
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace PF3.DTO.SoundCategory.Request;
|
namespace PyroFetes.DTO.Sound.Request;
|
||||||
|
|
||||||
public class UpdateSoundDto
|
public class UpdateSoundDto
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace PF3.DTO.SoundCategory.Response;
|
namespace PyroFetes.DTO.Sound.Response;
|
||||||
|
|
||||||
public class ReadSoundDto
|
public class ReadSoundDto
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace PF3.DTO.SoundCategory.Request;
|
namespace PyroFetes.DTO.SoundCategory.Request;
|
||||||
|
|
||||||
public class CreateSoundCategoryDto
|
public class CreateSoundCategoryDto
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace PF3.DTO.SoundCategory.Request;
|
namespace PyroFetes.DTO.SoundCategory.Request;
|
||||||
|
|
||||||
public class IdSoundCategoryDto
|
public class IdSoundCategoryDto
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace PF3.DTO.SoundCategory.Request;
|
namespace PyroFetes.DTO.SoundCategory.Request;
|
||||||
|
|
||||||
public class UpdateSoundCategoryDto
|
public class UpdateSoundCategoryDto
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace PF3.DTO.SoundCategory.Response;
|
namespace PyroFetes.DTO.SoundCategory.Response;
|
||||||
|
|
||||||
public class ReadSoundCategoryDto
|
public class ReadSoundCategoryDto
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace PF3.DTO.SoundTimecode.Request;
|
namespace PyroFetes.DTO.SoundTimecode.Request;
|
||||||
|
|
||||||
public class CreateSoundTimecodeDto
|
public class CreateSoundTimecodeDto
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace PF3.DTO.SoundTimecode.Request;
|
namespace PyroFetes.DTO.SoundTimecode.Request;
|
||||||
|
|
||||||
public class IdSoundTimecodeDto
|
public class IdSoundTimecodeDto
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace PF3.DTO.SoundTimecode.Request;
|
namespace PyroFetes.DTO.SoundTimecode.Request;
|
||||||
|
|
||||||
public class UpdateSoundTimecodeDto
|
public class UpdateSoundTimecodeDto
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace PF3.DTO.SoundTimecode.Response;
|
namespace PyroFetes.DTO.SoundTimecode.Response;
|
||||||
|
|
||||||
public class ReadSoundTimecodeDto
|
public class ReadSoundTimecodeDto
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace PF3.DTO.Staff.Request;
|
namespace PyroFetes.DTO.Staff.Request;
|
||||||
|
|
||||||
public class CreateStaffDto
|
public class CreateStaffDto
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace PF3.DTO.Staff.Request;
|
namespace PyroFetes.DTO.Staff.Request;
|
||||||
|
|
||||||
public class IdStaffDto
|
public class IdStaffDto
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace PF3.DTO.Staff.Request;
|
namespace PyroFetes.DTO.Staff.Request;
|
||||||
|
|
||||||
public class UpdateStaffDto
|
public class UpdateStaffDto
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace PF3.DTO.Staff.Response;
|
namespace PyroFetes.DTO.Staff.Response;
|
||||||
|
|
||||||
public class ReadStaffDto
|
public class ReadStaffDto
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
namespace PF3.DTO.Truck.Request;
|
namespace PyroFetes.DTO.Truck.Request;
|
||||||
|
|
||||||
public class CreateTruckDto
|
public class CreateTruckDto
|
||||||
{
|
{
|
||||||
public string? Type { get; set; }
|
public string? Type { get; set; }
|
||||||
public string? MaxExplosiveCapacity { get; set; }
|
public double? MaxExplosiveCapacity { get; set; }
|
||||||
public string? Sizes { get; set; }
|
public string? Sizes { get; set; }
|
||||||
public string? Statut { get; set; }
|
public string? Status { get; set; }
|
||||||
public int? ShowId { get; set; }
|
public int? ShowId { get; set; }
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace PF3.DTO.Truck.Request;
|
namespace PyroFetes.DTO.Truck.Request;
|
||||||
|
|
||||||
public class IdTruckDto
|
public class IdTruckDto
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace PF3.DTO.Truck.Request;
|
namespace PyroFetes.DTO.Truck.Request;
|
||||||
|
|
||||||
public class UpdateTruckDto
|
public class UpdateTruckDto
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
namespace PF3.DTO.Truck.Response;
|
namespace PyroFetes.DTO.Truck.Response;
|
||||||
|
|
||||||
public class ReadTruckDto
|
public class ReadTruckDto
|
||||||
{
|
{
|
||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
public string? Type { get; set; }
|
public string? Type { get; set; }
|
||||||
public string? MaxExplosiveCapacity { get; set; }
|
public double? MaxExplosiveCapacity { get; set; }
|
||||||
public string? Sizes { get; set; }
|
public string? Sizes { get; set; }
|
||||||
public string? Statut { get; set; }
|
public string? Statut { get; set; }
|
||||||
public int? ShowId { get; set; }
|
public int? ShowId { get; set; }
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using PF3.DTO.SoundCategory.Request;
|
using PyroFetes.DTO.SoundCategory.Request;
|
||||||
using PF3.DTO.SoundCategory.Response;
|
using PyroFetes.DTO.SoundCategory.Response;
|
||||||
using PF3.Models;
|
|
||||||
|
|
||||||
namespace PF3.Endpoints.SoundCategory;
|
namespace PyroFetes.Endpoints.SoundCategory;
|
||||||
|
|
||||||
public class CreateSoundCategoryEndpoint(PF3DbContext pf3DbContext) : Endpoint<CreateSoundCategoryDto, ReadSoundCategoryDto>
|
public class CreateSoundCategoryEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint<CreateSoundCategoryDto, ReadSoundCategoryDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
@@ -15,13 +14,13 @@ public class CreateSoundCategoryEndpoint(PF3DbContext pf3DbContext) : Endpoint<C
|
|||||||
|
|
||||||
public override async Task HandleAsync(CreateSoundCategoryDto req, CancellationToken ct)
|
public override async Task HandleAsync(CreateSoundCategoryDto req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
var soundCategory = new Models.SoundCategory
|
var soundCategory = new PyroFetes.Models.SoundCategory
|
||||||
{
|
{
|
||||||
Name = req.Name,
|
Name = req.Name,
|
||||||
};
|
};
|
||||||
|
|
||||||
pf3DbContext.SoundsCategorys.Add(soundCategory);
|
pyroFetesDbContext.SoundCategories.Add(soundCategory);
|
||||||
await pf3DbContext.SaveChangesAsync(ct);
|
await pyroFetesDbContext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
var result = new ReadSoundCategoryDto
|
var result = new ReadSoundCategoryDto
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using PF3.DTO.SoundCategory.Request;
|
using PyroFetes.DTO.SoundCategory.Request;
|
||||||
|
|
||||||
namespace PF3.Endpoints.SoundCategory;
|
namespace PyroFetes.Endpoints.SoundCategory;
|
||||||
|
|
||||||
public class DeleteSoundCategoryEndpoint(PF3DbContext pf3DbContext) : Endpoint<IdSoundCategoryDto>
|
public class DeleteSoundCategoryEndpoint(PyroFetesDbContext pf3DbContext) : Endpoint<IdSoundCategoryDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
@@ -14,14 +14,14 @@ public class DeleteSoundCategoryEndpoint(PF3DbContext pf3DbContext) : Endpoint<I
|
|||||||
|
|
||||||
public override async Task HandleAsync(IdSoundCategoryDto req, CancellationToken ct)
|
public override async Task HandleAsync(IdSoundCategoryDto req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
var soundCategory = await pf3DbContext.SoundsCategorys.FirstOrDefaultAsync(st => st.Id == req.Id, ct);
|
var soundCategory = await pf3DbContext.SoundCategories.FirstOrDefaultAsync(st => st.Id == req.Id, ct);
|
||||||
if (soundCategory is null)
|
if (soundCategory is null)
|
||||||
{
|
{
|
||||||
await Send.NotFoundAsync(ct);
|
await Send.NotFoundAsync(ct);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pf3DbContext.SoundsCategorys.Remove(soundCategory);
|
pf3DbContext.SoundCategories.Remove(soundCategory);
|
||||||
await pf3DbContext.SaveChangesAsync(ct);
|
await pf3DbContext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
await Send.OkAsync(ct);
|
await Send.OkAsync(ct);
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using PF3.DTO.SoundCategory.Response;
|
using PyroFetes.DTO.SoundCategory.Response;
|
||||||
|
|
||||||
namespace PF3.Endpoints.SoundCategory;
|
namespace PyroFetes.Endpoints.SoundCategory;
|
||||||
|
|
||||||
public class GetAllSoundCategorysEndpoint(PF3DbContext pf3DbContext) : EndpointWithoutRequest<List<ReadSoundCategoryDto>>
|
public class GetAllSoundCategorysEndpoint(PyroFetesDbContext pf3DbContext) : EndpointWithoutRequest<List<ReadSoundCategoryDto>>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
@@ -14,7 +14,7 @@ public class GetAllSoundCategorysEndpoint(PF3DbContext pf3DbContext) : EndpointW
|
|||||||
|
|
||||||
public override async Task HandleAsync(CancellationToken ct)
|
public override async Task HandleAsync(CancellationToken ct)
|
||||||
{
|
{
|
||||||
var soundCategorys = await pf3DbContext.SoundsCategorys.ToListAsync(ct);
|
var soundCategorys = await pf3DbContext.SoundCategories.ToListAsync(ct);
|
||||||
|
|
||||||
var result = soundCategorys.Select(sC => new ReadSoundCategoryDto
|
var result = soundCategorys.Select(sC => new ReadSoundCategoryDto
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using PF3.DTO.SoundCategory.Request;
|
using PyroFetes.DTO.SoundCategory.Request;
|
||||||
using PF3.DTO.SoundCategory.Response;
|
using PyroFetes.DTO.SoundCategory.Response;
|
||||||
|
|
||||||
namespace PF3.Endpoints.SoundCategory;
|
namespace PyroFetes.Endpoints.SoundCategory;
|
||||||
|
|
||||||
public class GetSoundCategoryEndpoint(PF3DbContext pf3DbContext) : Endpoint<IdSoundCategoryDto, ReadSoundCategoryDto>
|
public class GetSoundCategoryEndpoint(PyroFetesDbContext pf3DbContext) : Endpoint<IdSoundCategoryDto, ReadSoundCategoryDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
@@ -15,7 +15,7 @@ public class GetSoundCategoryEndpoint(PF3DbContext pf3DbContext) : Endpoint<IdSo
|
|||||||
|
|
||||||
public override async Task HandleAsync(IdSoundCategoryDto req, CancellationToken ct)
|
public override async Task HandleAsync(IdSoundCategoryDto req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
var soundCategory = await pf3DbContext.SoundsCategorys
|
var soundCategory = await pf3DbContext.SoundCategories
|
||||||
.Where(sc => sc.Id == req.Id)
|
.Where(sc => sc.Id == req.Id)
|
||||||
.Select(sc => new ReadSoundCategoryDto
|
.Select(sc => new ReadSoundCategoryDto
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using PF3.DTO.SoundCategory.Request;
|
using PyroFetes.DTO.SoundCategory.Request;
|
||||||
using PF3.DTO.SoundCategory.Response;
|
using PyroFetes.DTO.SoundCategory.Response;
|
||||||
|
|
||||||
namespace PF3.Endpoints.SoundCategory;
|
namespace PyroFetes.Endpoints.SoundCategory;
|
||||||
|
|
||||||
public class UpdateSoundCategoryEndpoint(PF3DbContext pf3DbContext) : Endpoint<UpdateSoundCategoryDto, ReadSoundCategoryDto>
|
public class UpdateSoundCategoryEndpoint(PyroFetesDbContext pf3DbContext) : Endpoint<UpdateSoundCategoryDto, ReadSoundCategoryDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
@@ -15,7 +15,7 @@ public class UpdateSoundCategoryEndpoint(PF3DbContext pf3DbContext) : Endpoint<U
|
|||||||
|
|
||||||
public override async Task HandleAsync(UpdateSoundCategoryDto req, CancellationToken ct)
|
public override async Task HandleAsync(UpdateSoundCategoryDto req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
var soundCategory = await pf3DbContext.SoundsCategorys.FirstOrDefaultAsync(st => st.Id == req.Id, ct);
|
var soundCategory = await pf3DbContext.SoundCategories.FirstOrDefaultAsync(st => st.Id == req.Id, ct);
|
||||||
if (soundCategory is null)
|
if (soundCategory is null)
|
||||||
{
|
{
|
||||||
await Send.NotFoundAsync(ct);
|
await Send.NotFoundAsync(ct);
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using PF3.DTO.Staff.Request;
|
using PyroFetes.DTO.Staff.Request;
|
||||||
using PF3.DTO.Staff.Response;
|
using PyroFetes.DTO.Staff.Response;
|
||||||
|
|
||||||
namespace PF3.Endpoints.Staff;
|
namespace PyroFetes.Endpoints.Staff;
|
||||||
|
|
||||||
public class CreateStaffEndpoint(PF3DbContext pf3DbContext):Endpoint<CreateStaffDto, ReadStaffDto>
|
public class CreateStaffEndpoint(PyroFetesDbContext pf3DbContext):Endpoint<CreateStaffDto, ReadStaffDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
@@ -14,7 +14,7 @@ public class CreateStaffEndpoint(PF3DbContext pf3DbContext):Endpoint<CreateStaff
|
|||||||
|
|
||||||
public override async Task HandleAsync(CreateStaffDto req, CancellationToken ct)
|
public override async Task HandleAsync(CreateStaffDto req, CancellationToken ct)
|
||||||
{
|
{
|
||||||
var staff = new Models.Staff
|
var staff = new PyroFetes.Models.Staff
|
||||||
{
|
{
|
||||||
FirstName = req.FirstName,
|
FirstName = req.FirstName,
|
||||||
LastName = req.LastName,
|
LastName = req.LastName,
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using PF3.DTO.Staff.Request;
|
using PyroFetes.DTO.Staff.Request;
|
||||||
|
|
||||||
namespace PF3.Endpoints.Staff;
|
namespace PyroFetes.Endpoints.Staff;
|
||||||
|
|
||||||
public class DeleteStaffEndpoint(PF3DbContext pf3DbContext) : Endpoint<IdStaffDto>
|
public class DeleteStaffEndpoint(PyroFetesDbContext pf3DbContext) : Endpoint<IdStaffDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using PF3.DTO.Staff.Response;
|
using PyroFetes.DTO.Staff.Response;
|
||||||
|
|
||||||
namespace PF3.Endpoints.Staff;
|
namespace PyroFetes.Endpoints.Staff;
|
||||||
|
|
||||||
public class GetAllStaffEndpoint(PF3DbContext pf3DbContext) : EndpointWithoutRequest<List<ReadStaffDto>>
|
public class GetAllStaffEndpoint(PyroFetesDbContext pf3DbContext) : EndpointWithoutRequest<List<ReadStaffDto>>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using PF3.DTO.Staff.Request;
|
using PyroFetes.DTO.Staff.Request;
|
||||||
using PF3.DTO.Staff.Response;
|
using PyroFetes.DTO.Staff.Response;
|
||||||
|
|
||||||
namespace PF3.Endpoints.Staff;
|
namespace PyroFetes.Endpoints.Staff;
|
||||||
|
|
||||||
public class GetStaffEndpoint(PF3DbContext pf3DbContext) : Endpoint<IdStaffDto, ReadStaffDto>
|
public class GetStaffEndpoint(PyroFetesDbContext pf3DbContext) : Endpoint<IdStaffDto, ReadStaffDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using PF3.DTO.Staff.Request;
|
using PyroFetes.DTO.Staff.Request;
|
||||||
using PF3.DTO.Staff.Response;
|
using PyroFetes.DTO.Staff.Response;
|
||||||
|
|
||||||
namespace PF3.Endpoints.Staff;
|
namespace PyroFetes.Endpoints.Staff;
|
||||||
|
|
||||||
public class UpdateStaffEndpoint(PF3DbContext pf3DbContext) : Endpoint<UpdateStaffDto, ReadStaffDto>
|
public class UpdateStaffEndpoint(PyroFetesDbContext pf3DbContext) : Endpoint<UpdateStaffDto, ReadStaffDto>
|
||||||
{
|
{
|
||||||
public override void Configure()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,41 +0,0 @@
|
|||||||
using FastEndpoints;
|
|
||||||
using PF3.DTO.Truck.Request;
|
|
||||||
using PF3.DTO.Truck.Response;
|
|
||||||
using PyroFetes;
|
|
||||||
|
|
||||||
namespace PF3.Endpoints.Truck;
|
|
||||||
|
|
||||||
public class CreateTruckEndpoint(PF3DbContext pf3DbContext):Endpoint<CreateTruckDto, ReadTruckDto>
|
|
||||||
{
|
|
||||||
public override void Configure()
|
|
||||||
{
|
|
||||||
Post("/api/truck");
|
|
||||||
AllowAnonymous();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override async Task HandleAsync(CreateTruckDto req, CancellationToken ct)
|
|
||||||
{
|
|
||||||
var truck = new Models.Truck
|
|
||||||
{
|
|
||||||
Type = req.Type,
|
|
||||||
MaxExplosiveCapacity = req.MaxExplosiveCapacity,
|
|
||||||
Sizes = req.Sizes,
|
|
||||||
Statut = req.Statut
|
|
||||||
};
|
|
||||||
|
|
||||||
pf3DbContext.Trucks.Add(truck);
|
|
||||||
await pf3DbContext.SaveChangesAsync(ct);
|
|
||||||
|
|
||||||
var result = new ReadTruckDto()
|
|
||||||
{
|
|
||||||
Id = truck.Id,
|
|
||||||
Type = truck.Type,
|
|
||||||
MaxExplosiveCapacity = truck.MaxExplosiveCapacity,
|
|
||||||
Sizes = truck.Sizes,
|
|
||||||
Statut = truck.Statut
|
|
||||||
};
|
|
||||||
|
|
||||||
await Send.OkAsync(result, ct);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
using PF3.DTO.Truck.Request;
|
|
||||||
using FastEndpoints;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using PF3;
|
|
||||||
|
|
||||||
namespace ApiLibrary.Endpoints.Truck;
|
|
||||||
|
|
||||||
public class DeleteTruckEndpoint(PF3DbContext pf3DbContext) : Endpoint<IdTruckDto>
|
|
||||||
{
|
|
||||||
public override void Configure()
|
|
||||||
{
|
|
||||||
Delete("/api/trucks/{@Id}", x => new { x.Id });
|
|
||||||
}
|
|
||||||
|
|
||||||
public override async Task HandleAsync(IdTruckDto req, CancellationToken ct)
|
|
||||||
{
|
|
||||||
var truck = await pf3DbContext.Trucks.FirstOrDefaultAsync(a => a.Id == req.Id, ct);
|
|
||||||
|
|
||||||
pf3DbContext.Trucks.Remove(truck);
|
|
||||||
await pf3DbContext.SaveChangesAsync(ct);
|
|
||||||
|
|
||||||
await Send.OkAsync(ct);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
using PF3.DTO.Truck.Response;
|
|
||||||
using FastEndpoints;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using PF3;
|
|
||||||
|
|
||||||
namespace PF3.Endpoints.Truck;
|
|
||||||
|
|
||||||
public class GetAllTrucksEndpoint(PF3DbContext pf3DbContext) : EndpointWithoutRequest<List<ReadTruckDto>>
|
|
||||||
{
|
|
||||||
public override void Configure()
|
|
||||||
{
|
|
||||||
Get("/api/trucks");
|
|
||||||
}
|
|
||||||
|
|
||||||
public override async Task HandleAsync(CancellationToken ct)
|
|
||||||
{
|
|
||||||
var trucks = await pf3DbContext.Trucks.ToListAsync(ct);
|
|
||||||
|
|
||||||
var result = trucks
|
|
||||||
.Select(truck => new ReadTruckDto
|
|
||||||
{
|
|
||||||
Id = truck.Id,
|
|
||||||
Type = truck.Type,
|
|
||||||
MaxExplosiveCapacity = truck.MaxExplosiveCapacity,
|
|
||||||
Sizes = truck.Sizes,
|
|
||||||
Statut = truck.Statut,
|
|
||||||
ShowId = truck.ShowId
|
|
||||||
})
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
await Send.OkAsync(result, ct);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
using PF3.DTO.Truck.Request;
|
|
||||||
using PF3.DTO.Truck.Response;
|
|
||||||
using FastEndpoints;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using PF3;
|
|
||||||
|
|
||||||
namespace PF3.Endpoints.Truck;
|
|
||||||
|
|
||||||
public class GetTruckEndpoint(PF3DbContext pf3DbContext) : Endpoint<IdTruckDto, ReadTruckDto>
|
|
||||||
{
|
|
||||||
public override void Configure()
|
|
||||||
{
|
|
||||||
Get("/api/trucks/{@Id}");
|
|
||||||
}
|
|
||||||
|
|
||||||
public override async Task HandleAsync(IdTruckDto req, CancellationToken ct)
|
|
||||||
{
|
|
||||||
var truck = await pf3DbContext.Trucks
|
|
||||||
.Where(t => t.Id == req.Id)
|
|
||||||
.Select(t => new ReadTruckDto
|
|
||||||
{
|
|
||||||
Id = t.Id,
|
|
||||||
Type = t.Type,
|
|
||||||
MaxExplosiveCapacity = t.MaxExplosiveCapacity,
|
|
||||||
Sizes = t.Sizes,
|
|
||||||
Statut = t.Statut,
|
|
||||||
ShowId = t.ShowId
|
|
||||||
})
|
|
||||||
.FirstOrDefaultAsync(ct);
|
|
||||||
|
|
||||||
if (truck is null)
|
|
||||||
{
|
|
||||||
await Send.NotFoundAsync(ct);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await Send.OkAsync(truck, ct);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
using PF3.DTO.Truck.Request;
|
|
||||||
using PF3.DTO.Truck.Response;
|
|
||||||
using FastEndpoints;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using PF3;
|
|
||||||
|
|
||||||
namespace PF3.Endpoints.Truck;
|
|
||||||
|
|
||||||
public class UpdateTruckEndpoint(PF3DbContext pf3DbContext) : Endpoint<UpdateTruckDto, ReadTruckDto>
|
|
||||||
{
|
|
||||||
public override void Configure()
|
|
||||||
{
|
|
||||||
Put("/api/trucks/{id}");
|
|
||||||
}
|
|
||||||
|
|
||||||
public override async Task HandleAsync(UpdateTruckDto req, CancellationToken ct)
|
|
||||||
{
|
|
||||||
var id = Route<int>("id");
|
|
||||||
|
|
||||||
var truck = await pf3DbContext.Trucks.FirstOrDefaultAsync(t => t.Id == id, ct);
|
|
||||||
|
|
||||||
if (truck is null)
|
|
||||||
{
|
|
||||||
await Send.NotFoundAsync(ct);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
truck.Type = req.Type;
|
|
||||||
truck.MaxExplosiveCapacity = req.MaxExplosiveCapacity;
|
|
||||||
truck.Sizes = req.Sizes;
|
|
||||||
truck.Statut = req.Statut;
|
|
||||||
truck.ShowId = req.ShowId;
|
|
||||||
|
|
||||||
await pf3DbContext.SaveChangesAsync(ct);
|
|
||||||
|
|
||||||
var result = new ReadTruckDto
|
|
||||||
{
|
|
||||||
Id = truck.Id,
|
|
||||||
Type = truck.Type,
|
|
||||||
MaxExplosiveCapacity = truck.MaxExplosiveCapacity,
|
|
||||||
Sizes = truck.Sizes,
|
|
||||||
Statut = truck.Statut,
|
|
||||||
ShowId = truck.ShowId
|
|
||||||
};
|
|
||||||
|
|
||||||
await Send.OkAsync(result, ct);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -7,6 +7,8 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="FastEndpoints" Version="7.1.1" />
|
||||||
|
<PackageReference Include="FastEndpoints.Swagger" Version="7.1.1" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.19"/>
|
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.19"/>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.20" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.20" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.20">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.20">
|
||||||
@@ -21,6 +23,7 @@
|
|||||||
<Folder Include="Endpoints\Show\" />
|
<Folder Include="Endpoints\Show\" />
|
||||||
<Folder Include="Endpoints\SoundTimecode\" />
|
<Folder Include="Endpoints\SoundTimecode\" />
|
||||||
<Folder Include="Endpoints\Sound\" />
|
<Folder Include="Endpoints\Sound\" />
|
||||||
|
<Folder Include="Endpoints\Truck\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -37,6 +37,10 @@ public class PyroFetesDbContext : DbContext
|
|||||||
public DbSet<QuotationProduct> QuotationProducts { get; set; }
|
public DbSet<QuotationProduct> QuotationProducts { get; set; }
|
||||||
public DbSet<Setting> Settings { get; set; }
|
public DbSet<Setting> Settings { get; set; }
|
||||||
public DbSet<Show> Shows { get; set; }
|
public DbSet<Show> Shows { get; set; }
|
||||||
|
|
||||||
|
// AJOUTE CETTE LIGNE ICI ⬇️
|
||||||
|
public DbSet<ShowTruck> ShowTrucks { get; set; }
|
||||||
|
|
||||||
public DbSet<Sound> Sounds { get; set; }
|
public DbSet<Sound> Sounds { get; set; }
|
||||||
public DbSet<SoundCategory> SoundCategories { get; set; }
|
public DbSet<SoundCategory> SoundCategories { get; set; }
|
||||||
public DbSet<SoundTimecode> SoundTimecodes { get; set; }
|
public DbSet<SoundTimecode> SoundTimecodes { get; set; }
|
||||||
|
|||||||
Reference in New Issue
Block a user