initalisation
This commit is contained in:
10
PyroFetes/DTO/Show/Request/CreateShowDto.cs
Normal file
10
PyroFetes/DTO/Show/Request/CreateShowDto.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace PF3.DTO.Show.Request;
|
||||
|
||||
public class CreateShowDto
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
public string? Place { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public string? PyrotechnicImplementationPlan { get; set; }
|
||||
public DateTime? Date { get; set; }
|
||||
}
|
||||
6
PyroFetes/DTO/Show/Request/IdShowDto.cs
Normal file
6
PyroFetes/DTO/Show/Request/IdShowDto.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace PF3.DTO.Show.Request;
|
||||
|
||||
public class IdShowDto
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
}
|
||||
11
PyroFetes/DTO/Show/Request/UpdateShowDto.cs
Normal file
11
PyroFetes/DTO/Show/Request/UpdateShowDto.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace PF3.DTO.Show.Request;
|
||||
|
||||
public class UpdateShowDto
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public string? Place { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public string? PyrotechnicImplementationPlan { get; set; }
|
||||
public DateTime? Date { get; set; }
|
||||
}
|
||||
11
PyroFetes/DTO/Show/Response/ReadShowDto.cs
Normal file
11
PyroFetes/DTO/Show/Response/ReadShowDto.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace PF3.DTO.Show.Response;
|
||||
|
||||
public class ReadShowDto
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public string? Place { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public string? PyrotechnicImplementationPlan { get; set; }
|
||||
public DateTime? Date { get; set; }
|
||||
}
|
||||
14
PyroFetes/DTO/Sound/Request/CreateSoundDto.cs
Normal file
14
PyroFetes/DTO/Sound/Request/CreateSoundDto.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace PF3.DTO.SoundCategory.Request;
|
||||
|
||||
public class CreateSoundDto
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
public string? Type { get; set; }
|
||||
public string? Artist { get; set; }
|
||||
public string? Duration { get; set; }
|
||||
public string? Kind { get; set; }
|
||||
public string? Format { get; set; }
|
||||
public DateTime? CreationDate { get; set; }
|
||||
public string? SoundCategoryId { get; set; }
|
||||
|
||||
}
|
||||
6
PyroFetes/DTO/Sound/Request/IdSoundto.cs
Normal file
6
PyroFetes/DTO/Sound/Request/IdSoundto.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace PF3.DTO.SoundCategory.Request;
|
||||
|
||||
public class IdSoundto
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
}
|
||||
15
PyroFetes/DTO/Sound/Request/UpdateSoundDto.cs
Normal file
15
PyroFetes/DTO/Sound/Request/UpdateSoundDto.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
namespace PF3.DTO.SoundCategory.Request;
|
||||
|
||||
public class UpdateSoundDto
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public string? Type { get; set; }
|
||||
public string? Artist { get; set; }
|
||||
public string? Duration { get; set; }
|
||||
public string? Kind { get; set; }
|
||||
public string? Format { get; set; }
|
||||
public DateTime? CreationDate { get; set; }
|
||||
public string? SoundCategoryId { get; set; }
|
||||
|
||||
}
|
||||
15
PyroFetes/DTO/Sound/Response/ReadSoundDto.cs
Normal file
15
PyroFetes/DTO/Sound/Response/ReadSoundDto.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
namespace PF3.DTO.SoundCategory.Response;
|
||||
|
||||
public class ReadSoundDto
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public string? Type { get; set; }
|
||||
public string? Artist { get; set; }
|
||||
public string? Duration { get; set; }
|
||||
public string? Kind { get; set; }
|
||||
public string? Format { get; set; }
|
||||
public DateTime? CreationDate { get; set; }
|
||||
public string? SoundCategoryId { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace PF3.DTO.SoundCategory.Request;
|
||||
|
||||
public class CreateSoundCategoryDto
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace PF3.DTO.SoundCategory.Request;
|
||||
|
||||
public class IdSoundCategoryDto
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace PF3.DTO.SoundCategory.Request;
|
||||
|
||||
public class UpdateSoundCategoryDto
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace PF3.DTO.SoundCategory.Response;
|
||||
|
||||
public class ReadSoundCategoryDto
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace PF3.DTO.SoundTimecode.Request;
|
||||
|
||||
public class CreateSoundTimecodeDto
|
||||
{
|
||||
public int ShowId { get; set; }
|
||||
public int SoundId { get; set; }
|
||||
public int Start { get; set; }
|
||||
public int End { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace PF3.DTO.SoundTimecode.Request;
|
||||
|
||||
public class IdSoundTimecodeDto
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace PF3.DTO.SoundTimecode.Request;
|
||||
|
||||
public class UpdateSoundTimecodeDto
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public int ShowId { get; set; }
|
||||
public int SoundId { get; set; }
|
||||
public int Start { get; set; }
|
||||
public int End { get; set; }
|
||||
}
|
||||
10
PyroFetes/DTO/SoundTimecode/Response/ReadSoundTimecodeDto.cs
Normal file
10
PyroFetes/DTO/SoundTimecode/Response/ReadSoundTimecodeDto.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace PF3.DTO.SoundTimecode.Response;
|
||||
|
||||
public class ReadSoundTimecodeDto
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public int? ShowId { get; set; }
|
||||
public int? SoundId { get; set; }
|
||||
public int Start { get; set; }
|
||||
public int End { get; set; }
|
||||
}
|
||||
9
PyroFetes/DTO/Staff/Request/CreateStaffDto.cs
Normal file
9
PyroFetes/DTO/Staff/Request/CreateStaffDto.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace PF3.DTO.Staff.Request;
|
||||
|
||||
public class CreateStaffDto
|
||||
{
|
||||
public string? FirstName { get; set; }
|
||||
public string? LastName { get; set; }
|
||||
public string? Profession { get; set; }
|
||||
public string? Email { get; set; }
|
||||
}
|
||||
6
PyroFetes/DTO/Staff/Request/IdStaffDto.cs
Normal file
6
PyroFetes/DTO/Staff/Request/IdStaffDto.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace PF3.DTO.Staff.Request;
|
||||
|
||||
public class IdStaffDto
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
}
|
||||
10
PyroFetes/DTO/Staff/Request/UpdateStaffDto.cs
Normal file
10
PyroFetes/DTO/Staff/Request/UpdateStaffDto.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace PF3.DTO.Staff.Request;
|
||||
|
||||
public class UpdateStaffDto
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? FirstName { get; set; }
|
||||
public string? LastName { get; set; }
|
||||
public string? Profession { get; set; }
|
||||
public string? Email { get; set; }
|
||||
}
|
||||
10
PyroFetes/DTO/Staff/Response/ReadStaffDto.cs
Normal file
10
PyroFetes/DTO/Staff/Response/ReadStaffDto.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace PF3.DTO.Staff.Response;
|
||||
|
||||
public class ReadStaffDto
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? FirstName { get; set; }
|
||||
public string? LastName { get; set; }
|
||||
public string? Profession { get; set; }
|
||||
public string? Email { get; set; }
|
||||
}
|
||||
10
PyroFetes/DTO/Truck/Request/CreateTruckDto.cs
Normal file
10
PyroFetes/DTO/Truck/Request/CreateTruckDto.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace PF3.DTO.Truck.Request;
|
||||
|
||||
public class CreateTruckDto
|
||||
{
|
||||
public string? Type { get; set; }
|
||||
public string? MaxExplosiveCapacity { get; set; }
|
||||
public string? Sizes { get; set; }
|
||||
public string? Statut { get; set; }
|
||||
public int? ShowId { get; set; }
|
||||
}
|
||||
6
PyroFetes/DTO/Truck/Request/IdTruckDto.cs
Normal file
6
PyroFetes/DTO/Truck/Request/IdTruckDto.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace PF3.DTO.Truck.Request;
|
||||
|
||||
public class IdTruckDto
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
}
|
||||
11
PyroFetes/DTO/Truck/Request/UpdateTruckDto.cs
Normal file
11
PyroFetes/DTO/Truck/Request/UpdateTruckDto.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace PF3.DTO.Truck.Request;
|
||||
|
||||
public class UpdateTruckDto
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Type { get; set; }
|
||||
public string? MaxExplosiveCapacity { get; set; }
|
||||
public string? Sizes { get; set; }
|
||||
public string? Statut { get; set; }
|
||||
public int? ShowId { get; set; }
|
||||
}
|
||||
11
PyroFetes/DTO/Truck/Response/ReadTruckDto.cs
Normal file
11
PyroFetes/DTO/Truck/Response/ReadTruckDto.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace PF3.DTO.Truck.Response;
|
||||
|
||||
public class ReadTruckDto
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Type { get; set; }
|
||||
public string? MaxExplosiveCapacity { get; set; }
|
||||
public string? Sizes { get; set; }
|
||||
public string? Statut { get; set; }
|
||||
public int? ShowId { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using FastEndpoints;
|
||||
using PF3.DTO.SoundCategory.Request;
|
||||
using PF3.DTO.SoundCategory.Response;
|
||||
using PF3.Models;
|
||||
|
||||
namespace PF3.Endpoints.SoundCategory;
|
||||
|
||||
public class CreateSoundCategoryEndpoint(PF3DbContext pf3DbContext) : Endpoint<CreateSoundCategoryDto, ReadSoundCategoryDto>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Post("/api/soundcategorys");
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(CreateSoundCategoryDto req, CancellationToken ct)
|
||||
{
|
||||
var soundCategory = new Models.SoundCategory
|
||||
{
|
||||
Name = req.Name,
|
||||
};
|
||||
|
||||
pf3DbContext.SoundsCategorys.Add(soundCategory);
|
||||
await pf3DbContext.SaveChangesAsync(ct);
|
||||
|
||||
var result = new ReadSoundCategoryDto
|
||||
{
|
||||
Id = soundCategory.Id,
|
||||
Name = soundCategory.Name
|
||||
};
|
||||
|
||||
await Send.OkAsync(result, ct);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using FastEndpoints;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PF3.DTO.SoundCategory.Request;
|
||||
|
||||
namespace PF3.Endpoints.SoundCategory;
|
||||
|
||||
public class DeleteSoundCategoryEndpoint(PF3DbContext pf3DbContext) : Endpoint<IdSoundCategoryDto>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Delete("/api/soundcategorys/{Id}");
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(IdSoundCategoryDto req, CancellationToken ct)
|
||||
{
|
||||
var soundCategory = await pf3DbContext.SoundsCategorys.FirstOrDefaultAsync(st => st.Id == req.Id, ct);
|
||||
if (soundCategory is null)
|
||||
{
|
||||
await Send.NotFoundAsync(ct);
|
||||
return;
|
||||
}
|
||||
|
||||
pf3DbContext.SoundsCategorys.Remove(soundCategory);
|
||||
await pf3DbContext.SaveChangesAsync(ct);
|
||||
|
||||
await Send.OkAsync(ct);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using FastEndpoints;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PF3.DTO.SoundCategory.Response;
|
||||
|
||||
namespace PF3.Endpoints.SoundCategory;
|
||||
|
||||
public class GetAllSoundCategorysEndpoint(PF3DbContext pf3DbContext) : EndpointWithoutRequest<List<ReadSoundCategoryDto>>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Get("/api/soundcategorys");
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(CancellationToken ct)
|
||||
{
|
||||
var soundCategorys = await pf3DbContext.SoundsCategorys.ToListAsync(ct);
|
||||
|
||||
var result = soundCategorys.Select(sC => new ReadSoundCategoryDto
|
||||
{
|
||||
Id = sC.Id,
|
||||
Name = sC.Name
|
||||
}).ToList();
|
||||
|
||||
await Send.OkAsync(result, ct);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using FastEndpoints;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PF3.DTO.SoundCategory.Request;
|
||||
using PF3.DTO.SoundCategory.Response;
|
||||
|
||||
namespace PF3.Endpoints.SoundCategory;
|
||||
|
||||
public class GetSoundCategoryEndpoint(PF3DbContext pf3DbContext) : Endpoint<IdSoundCategoryDto, ReadSoundCategoryDto>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Get("/api/soundcategorys/{Id}");
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(IdSoundCategoryDto req, CancellationToken ct)
|
||||
{
|
||||
var soundCategory = await pf3DbContext.SoundsCategorys
|
||||
.Where(sc => sc.Id == req.Id)
|
||||
.Select(sc => new ReadSoundCategoryDto
|
||||
{
|
||||
Id = sc.Id,
|
||||
Name = sc.Name,
|
||||
})
|
||||
.FirstOrDefaultAsync(ct);
|
||||
|
||||
if (soundCategory is null)
|
||||
{
|
||||
await Send.NotFoundAsync(ct);
|
||||
return;
|
||||
}
|
||||
|
||||
await Send.OkAsync(soundCategory, ct);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using FastEndpoints;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PF3.DTO.SoundCategory.Request;
|
||||
using PF3.DTO.SoundCategory.Response;
|
||||
|
||||
namespace PF3.Endpoints.SoundCategory;
|
||||
|
||||
public class UpdateSoundCategoryEndpoint(PF3DbContext pf3DbContext) : Endpoint<UpdateSoundCategoryDto, ReadSoundCategoryDto>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Patch("/api/soundcategorys/{Id}/name");
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(UpdateSoundCategoryDto req, CancellationToken ct)
|
||||
{
|
||||
var soundCategory = await pf3DbContext.SoundsCategorys.FirstOrDefaultAsync(st => st.Id == req.Id, ct);
|
||||
if (soundCategory is null)
|
||||
{
|
||||
await Send.NotFoundAsync(ct);
|
||||
return;
|
||||
}
|
||||
|
||||
soundCategory.Name = req.Name;
|
||||
|
||||
await pf3DbContext.SaveChangesAsync(ct);
|
||||
|
||||
var result = new ReadSoundCategoryDto
|
||||
{
|
||||
Id = soundCategory.Id,
|
||||
Name = soundCategory.Name
|
||||
};
|
||||
|
||||
await Send.OkAsync(result, ct);
|
||||
}
|
||||
}
|
||||
40
PyroFetes/Endpoints/Staff/CreateStaffEndpoint.cs
Normal file
40
PyroFetes/Endpoints/Staff/CreateStaffEndpoint.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using FastEndpoints;
|
||||
using PF3.DTO.Staff.Request;
|
||||
using PF3.DTO.Staff.Response;
|
||||
|
||||
namespace PF3.Endpoints.Staff;
|
||||
|
||||
public class CreateStaffEndpoint(PF3DbContext pf3DbContext):Endpoint<CreateStaffDto, ReadStaffDto>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Post("/api/staff");
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(CreateStaffDto req, CancellationToken ct)
|
||||
{
|
||||
var staff = new Models.Staff
|
||||
{
|
||||
FirstName = req.FirstName,
|
||||
LastName = req.LastName,
|
||||
Profession = req.Profession,
|
||||
Email = req.Email
|
||||
};
|
||||
|
||||
pf3DbContext.Staffs.Add(staff);
|
||||
await pf3DbContext.SaveChangesAsync(ct);
|
||||
|
||||
var result = new ReadStaffDto()
|
||||
{
|
||||
Id = staff.Id,
|
||||
FirstName = req.FirstName,
|
||||
LastName = req.LastName,
|
||||
Profession = req.Profession,
|
||||
Email = req.Email
|
||||
};
|
||||
|
||||
await Send.OkAsync(result, ct);
|
||||
|
||||
}
|
||||
}
|
||||
29
PyroFetes/Endpoints/Staff/DeleteStaffEndpoint.cs
Normal file
29
PyroFetes/Endpoints/Staff/DeleteStaffEndpoint.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using FastEndpoints;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PF3.DTO.Staff.Request;
|
||||
|
||||
namespace PF3.Endpoints.Staff;
|
||||
|
||||
public class DeleteStaffEndpoint(PF3DbContext pf3DbContext) : Endpoint<IdStaffDto>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Delete("/api/staff/{Id}");
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(IdStaffDto req, CancellationToken ct)
|
||||
{
|
||||
var staff = await pf3DbContext.Staffs.FirstOrDefaultAsync(s => s.Id == req.Id, ct);
|
||||
if (staff is null)
|
||||
{
|
||||
await Send.NotFoundAsync(ct);
|
||||
return;
|
||||
}
|
||||
|
||||
pf3DbContext.Staffs.Remove(staff);
|
||||
await pf3DbContext.SaveChangesAsync(ct);
|
||||
|
||||
await Send.OkAsync(ct);
|
||||
}
|
||||
}
|
||||
30
PyroFetes/Endpoints/Staff/GetAllStaffEndpoint.cs
Normal file
30
PyroFetes/Endpoints/Staff/GetAllStaffEndpoint.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using FastEndpoints;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PF3.DTO.Staff.Response;
|
||||
|
||||
namespace PF3.Endpoints.Staff;
|
||||
|
||||
public class GetAllStaffEndpoint(PF3DbContext pf3DbContext) : EndpointWithoutRequest<List<ReadStaffDto>>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Get("/api/staff");
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(CancellationToken ct)
|
||||
{
|
||||
var staffs = await pf3DbContext.Staffs.ToListAsync(ct);
|
||||
|
||||
var result = staffs.Select(s => new ReadStaffDto
|
||||
{
|
||||
Id = s.Id,
|
||||
FirstName = s.FirstName,
|
||||
LastName = s.LastName,
|
||||
Profession = s.Profession,
|
||||
Email = s.Email
|
||||
}).ToList();
|
||||
|
||||
await Send.OkAsync(result, ct);
|
||||
}
|
||||
}
|
||||
38
PyroFetes/Endpoints/Staff/GetStaffEndpoint.cs
Normal file
38
PyroFetes/Endpoints/Staff/GetStaffEndpoint.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using FastEndpoints;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PF3.DTO.Staff.Request;
|
||||
using PF3.DTO.Staff.Response;
|
||||
|
||||
namespace PF3.Endpoints.Staff;
|
||||
|
||||
public class GetStaffEndpoint(PF3DbContext pf3DbContext) : Endpoint<IdStaffDto, ReadStaffDto>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Get("/api/staff/{Id}");
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(IdStaffDto req, CancellationToken ct)
|
||||
{
|
||||
var staff = await pf3DbContext.Staffs
|
||||
.Where(s => s.Id == req.Id)
|
||||
.Select(s => new ReadStaffDto
|
||||
{
|
||||
Id = s.Id,
|
||||
FirstName = s.FirstName,
|
||||
LastName = s.LastName,
|
||||
Profession = s.Profession,
|
||||
Email = s.Email
|
||||
})
|
||||
.FirstOrDefaultAsync(ct);
|
||||
|
||||
if (staff is null)
|
||||
{
|
||||
await Send.NotFoundAsync(ct);
|
||||
return;
|
||||
}
|
||||
|
||||
await Send.OkAsync(staff, ct);
|
||||
}
|
||||
}
|
||||
43
PyroFetes/Endpoints/Staff/UpdateStaffEndpoint.cs
Normal file
43
PyroFetes/Endpoints/Staff/UpdateStaffEndpoint.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using FastEndpoints;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PF3.DTO.Staff.Request;
|
||||
using PF3.DTO.Staff.Response;
|
||||
|
||||
namespace PF3.Endpoints.Staff;
|
||||
|
||||
public class UpdateStaffEndpoint(PF3DbContext pf3DbContext) : Endpoint<UpdateStaffDto, ReadStaffDto>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Put("/api/staff/{Id}");
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(UpdateStaffDto req, CancellationToken ct)
|
||||
{
|
||||
var staff = await pf3DbContext.Staffs.FirstOrDefaultAsync(s => s.Id == req.Id, ct);
|
||||
if (staff is null)
|
||||
{
|
||||
await Send.NotFoundAsync(ct);
|
||||
return;
|
||||
}
|
||||
|
||||
staff.FirstName = req.FirstName;
|
||||
staff.LastName = req.LastName;
|
||||
staff.Profession = req.Profession;
|
||||
staff.Email = req.Email;
|
||||
|
||||
await pf3DbContext.SaveChangesAsync(ct);
|
||||
|
||||
var result = new ReadStaffDto
|
||||
{
|
||||
Id = staff.Id,
|
||||
FirstName = staff.FirstName,
|
||||
LastName = staff.LastName,
|
||||
Profession = staff.Profession,
|
||||
Email = staff.Email
|
||||
};
|
||||
|
||||
await Send.OkAsync(result, ct);
|
||||
}
|
||||
}
|
||||
41
PyroFetes/Endpoints/Truck/CreateTruckEndpoint.cs
Normal file
41
PyroFetes/Endpoints/Truck/CreateTruckEndpoint.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
24
PyroFetes/Endpoints/Truck/DeleteTruckEndpoint.cs
Normal file
24
PyroFetes/Endpoints/Truck/DeleteTruckEndpoint.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
33
PyroFetes/Endpoints/Truck/GetAllTruckEndpoint.cs
Normal file
33
PyroFetes/Endpoints/Truck/GetAllTruckEndpoint.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
39
PyroFetes/Endpoints/Truck/GetTruckEndpoint.cs
Normal file
39
PyroFetes/Endpoints/Truck/GetTruckEndpoint.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
48
PyroFetes/Endpoints/Truck/UpdateTruckEndpoint.cs
Normal file
48
PyroFetes/Endpoints/Truck/UpdateTruckEndpoint.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -17,4 +17,10 @@
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Endpoints\Show\" />
|
||||
<Folder Include="Endpoints\SoundTimecode\" />
|
||||
<Folder Include="Endpoints\Sound\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user