Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b3612f5bec | |||
| 6c1330e570 | |||
| 3a09bfc8ad | |||
| 5c12a45ae6 | |||
| 55f92ad761 | |||
| 6a813fc35a | |||
| a93d399942 |
@@ -0,0 +1,11 @@
|
|||||||
|
namespace PyroFetes.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; }
|
||||||
|
public int? CityId { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace PyroFetes.DTO.Show.Request;
|
||||||
|
|
||||||
|
public class IdShowDto
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
namespace PyroFetes.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; }
|
||||||
|
public int? CityId { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
namespace PyroFetes.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; }
|
||||||
|
public int? CityId { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
namespace PyroFetes.DTO.Sound.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; }
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace PyroFetes.DTO.Sound.Request;
|
||||||
|
|
||||||
|
public class IdSoundto
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
namespace PyroFetes.DTO.Sound.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; }
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
namespace PyroFetes.DTO.Sound.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 PyroFetes.DTO.SoundCategory.Request;
|
||||||
|
|
||||||
|
public class CreateSoundCategoryDto
|
||||||
|
{
|
||||||
|
public string? Name { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace PyroFetes.DTO.SoundCategory.Request;
|
||||||
|
|
||||||
|
public class IdSoundCategoryDto
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
namespace PyroFetes.DTO.SoundCategory.Request;
|
||||||
|
|
||||||
|
public class UpdateSoundCategoryDto
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
public string? Name { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
namespace PyroFetes.DTO.SoundCategory.Response;
|
||||||
|
|
||||||
|
public class ReadSoundCategoryDto
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
public string? Name { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
namespace PyroFetes.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 PyroFetes.DTO.SoundTimecode.Request;
|
||||||
|
|
||||||
|
public class IdSoundTimecodeDto
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
namespace PyroFetes.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; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
namespace PyroFetes.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; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
namespace PyroFetes.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; }
|
||||||
|
public string? F4T2NumberApproval { get; set; }
|
||||||
|
public DateOnly F4T2ExpirationDate { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace PyroFetes.DTO.Staff.Request;
|
||||||
|
|
||||||
|
public class IdStaffDto
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
namespace PyroFetes.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; }
|
||||||
|
public string? F4T2NumberApproval { get; set; }
|
||||||
|
public DateOnly? F4T2ExpirationDate { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
namespace PyroFetes.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; }
|
||||||
|
public string? F4T2NumberApproval { get; set; }
|
||||||
|
public DateOnly F4T2ExpirationDate { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
namespace PyroFetes.DTO.Truck.Request;
|
||||||
|
|
||||||
|
public class CreateTruckDto
|
||||||
|
{
|
||||||
|
public string? Type { get; set; }
|
||||||
|
public double? MaxExplosiveCapacity { get; set; }
|
||||||
|
public string? Sizes { get; set; }
|
||||||
|
public string? Status { get; set; }
|
||||||
|
public int? ShowId { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace PyroFetes.DTO.Truck.Request;
|
||||||
|
|
||||||
|
public class IdTruckDto
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
namespace PyroFetes.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; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
namespace PyroFetes.DTO.Truck.Response;
|
||||||
|
|
||||||
|
public class ReadTruckDto
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
public string? Type { get; set; }
|
||||||
|
public double? MaxExplosiveCapacity { get; set; }
|
||||||
|
public string? Sizes { get; set; }
|
||||||
|
public string? Statut { get; set; }
|
||||||
|
public int? ShowId { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
using FastEndpoints;
|
||||||
|
using PyroFetes.DTO.Show.Request;
|
||||||
|
using PyroFetes.DTO.Show.Response;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.Show;
|
||||||
|
|
||||||
|
public class CreateShowEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint<CreateShowDto, ReadShowDto>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Post("/shows");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(CreateShowDto req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
var show = new PyroFetes.Models.Show
|
||||||
|
{
|
||||||
|
Name = req.Name ?? string.Empty,
|
||||||
|
Place = req.Place ?? string.Empty,
|
||||||
|
Description = req.Description,
|
||||||
|
PyrotechnicImplementationPlan = req.PyrotechnicImplementationPlan ?? string.Empty,
|
||||||
|
Date = req.Date.HasValue ? DateOnly.FromDateTime(req.Date.Value) : null,
|
||||||
|
CityId = req.CityId
|
||||||
|
};
|
||||||
|
|
||||||
|
pyroFetesDbContext.Shows.Add(show);
|
||||||
|
await pyroFetesDbContext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
|
var result = new ReadShowDto
|
||||||
|
{
|
||||||
|
Id = show.Id,
|
||||||
|
Name = show.Name,
|
||||||
|
Place = show.Place,
|
||||||
|
Description = show.Description,
|
||||||
|
PyrotechnicImplementationPlan = show.PyrotechnicImplementationPlan,
|
||||||
|
Date = show.Date.HasValue ? show.Date.Value.ToDateTime(TimeOnly.MinValue) : null,
|
||||||
|
CityId = show.CityId
|
||||||
|
};
|
||||||
|
|
||||||
|
await Send.OkAsync(result, ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PyroFetes.DTO.Show.Request;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.Show;
|
||||||
|
|
||||||
|
public class DeleteShowEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint<IdShowDto>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Delete("/shows/{Id}");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(IdShowDto req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
if (!req.Id.HasValue)
|
||||||
|
{
|
||||||
|
await Send.NotFoundAsync(ct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var show = await pyroFetesDbContext.Shows
|
||||||
|
.FirstOrDefaultAsync(s => s.Id == req.Id.Value, ct);
|
||||||
|
|
||||||
|
if (show is null)
|
||||||
|
{
|
||||||
|
await Send.NotFoundAsync(ct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pyroFetesDbContext.Shows.Remove(show);
|
||||||
|
await pyroFetesDbContext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
|
await Send.OkAsync(ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PyroFetes.DTO.Show.Response;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.Show;
|
||||||
|
|
||||||
|
public class GetAllShowsEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest<List<ReadShowDto>>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Get("/shows");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(CancellationToken ct)
|
||||||
|
{
|
||||||
|
var shows = await pyroFetesDbContext.Shows
|
||||||
|
.Select(s => new ReadShowDto
|
||||||
|
{
|
||||||
|
Id = s.Id,
|
||||||
|
Name = s.Name,
|
||||||
|
Place = s.Place,
|
||||||
|
Description = s.Description,
|
||||||
|
PyrotechnicImplementationPlan = s.PyrotechnicImplementationPlan,
|
||||||
|
Date = s.Date.HasValue ? s.Date.Value.ToDateTime(TimeOnly.MinValue) : null,
|
||||||
|
CityId = s.CityId
|
||||||
|
})
|
||||||
|
.ToListAsync(ct);
|
||||||
|
|
||||||
|
await Send.OkAsync(shows, ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PyroFetes.DTO.Show.Request;
|
||||||
|
using PyroFetes.DTO.Show.Response;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.Show;
|
||||||
|
|
||||||
|
public class GetShowEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint<IdShowDto, ReadShowDto>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Get("/shows/{Id}");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(IdShowDto req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
if (!req.Id.HasValue)
|
||||||
|
{
|
||||||
|
await Send.NotFoundAsync(ct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var show = await pyroFetesDbContext.Shows
|
||||||
|
.Where(s => s.Id == req.Id.Value)
|
||||||
|
.Select(s => new ReadShowDto
|
||||||
|
{
|
||||||
|
Id = s.Id,
|
||||||
|
Name = s.Name,
|
||||||
|
Place = s.Place,
|
||||||
|
Description = s.Description,
|
||||||
|
PyrotechnicImplementationPlan = s.PyrotechnicImplementationPlan,
|
||||||
|
Date = s.Date.HasValue ? s.Date.Value.ToDateTime(TimeOnly.MinValue) : null,
|
||||||
|
CityId = s.CityId
|
||||||
|
})
|
||||||
|
.FirstOrDefaultAsync(ct);
|
||||||
|
|
||||||
|
if (show is null)
|
||||||
|
{
|
||||||
|
await Send.NotFoundAsync(ct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await Send.OkAsync(show, ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PyroFetes.DTO.Show.Request;
|
||||||
|
using PyroFetes.DTO.Show.Response;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.Show;
|
||||||
|
|
||||||
|
public class UpdateShowEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint<UpdateShowDto, ReadShowDto>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Put("/shows/{Id}");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(UpdateShowDto req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
if (!req.Id.HasValue)
|
||||||
|
{
|
||||||
|
await Send.NotFoundAsync(ct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var show = await pyroFetesDbContext.Shows
|
||||||
|
.FirstOrDefaultAsync(s => s.Id == req.Id.Value, ct);
|
||||||
|
|
||||||
|
if (show is null)
|
||||||
|
{
|
||||||
|
await Send.NotFoundAsync(ct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
show.Name = req.Name ?? show.Name;
|
||||||
|
show.Place = req.Place ?? show.Place;
|
||||||
|
show.Description = req.Description ?? show.Description;
|
||||||
|
show.PyrotechnicImplementationPlan = req.PyrotechnicImplementationPlan ?? show.PyrotechnicImplementationPlan;
|
||||||
|
if (req.CityId.HasValue) show.CityId = req.CityId.Value;
|
||||||
|
if (req.Date.HasValue) show.Date = DateOnly.FromDateTime(req.Date.Value);
|
||||||
|
|
||||||
|
await pyroFetesDbContext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
|
var result = new ReadShowDto
|
||||||
|
{
|
||||||
|
Id = show.Id,
|
||||||
|
Name = show.Name,
|
||||||
|
Place = show.Place,
|
||||||
|
Description = show.Description,
|
||||||
|
PyrotechnicImplementationPlan = show.PyrotechnicImplementationPlan,
|
||||||
|
Date = show.Date.HasValue ? show.Date.Value.ToDateTime(TimeOnly.MinValue) : null,
|
||||||
|
CityId = show.CityId
|
||||||
|
};
|
||||||
|
|
||||||
|
await Send.OkAsync(result, ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
using FastEndpoints;
|
||||||
|
using PyroFetes.DTO.Sound.Request;
|
||||||
|
using PyroFetes.DTO.Sound.Response;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.Sound;
|
||||||
|
|
||||||
|
public class CreateSoundEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint<CreateSoundDto, ReadSoundDto>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Post("/sounds");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(CreateSoundDto req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
var sound = new PyroFetes.Models.Sound
|
||||||
|
{
|
||||||
|
Name = req.Name ?? string.Empty,
|
||||||
|
Type = req.Type,
|
||||||
|
Artist = req.Artist,
|
||||||
|
Duration = int.TryParse(req.Duration, out var duration) ? duration : null,
|
||||||
|
Kind = req.Kind,
|
||||||
|
Format = req.Format,
|
||||||
|
CreationDate = req.CreationDate,
|
||||||
|
SoundCategoryId = int.TryParse(req.SoundCategoryId, out var categoryId) ? categoryId : 0
|
||||||
|
};
|
||||||
|
|
||||||
|
pyroFetesDbContext.Sounds.Add(sound);
|
||||||
|
await pyroFetesDbContext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
|
var result = new ReadSoundDto
|
||||||
|
{
|
||||||
|
Id = sound.Id,
|
||||||
|
Name = sound.Name,
|
||||||
|
Type = sound.Type,
|
||||||
|
Artist = sound.Artist,
|
||||||
|
Duration = sound.Duration?.ToString(),
|
||||||
|
Kind = sound.Kind,
|
||||||
|
Format = sound.Format,
|
||||||
|
CreationDate = sound.CreationDate,
|
||||||
|
SoundCategoryId = sound.SoundCategoryId.ToString()
|
||||||
|
};
|
||||||
|
|
||||||
|
await Send.OkAsync(result, ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PyroFetes.DTO.Sound.Request;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.Sound;
|
||||||
|
|
||||||
|
public class DeleteSoundEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint<IdSoundto>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Delete("/sounds/{Id}");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(IdSoundto req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
if (!req.Id.HasValue)
|
||||||
|
{
|
||||||
|
await Send.NotFoundAsync(ct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var sound = await pyroFetesDbContext.Sounds
|
||||||
|
.Include(s => s.SoundTimecodes)
|
||||||
|
.FirstOrDefaultAsync(s => s.Id == req.Id.Value, ct);
|
||||||
|
|
||||||
|
if (sound is null)
|
||||||
|
{
|
||||||
|
await Send.NotFoundAsync(ct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Supprimer les relations SoundTimecode associées si nécessaire
|
||||||
|
if (sound.SoundTimecodes != null && sound.SoundTimecodes.Any())
|
||||||
|
{
|
||||||
|
pyroFetesDbContext.SoundTimecodes.RemoveRange(sound.SoundTimecodes);
|
||||||
|
}
|
||||||
|
|
||||||
|
pyroFetesDbContext.Sounds.Remove(sound);
|
||||||
|
await pyroFetesDbContext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
|
await Send.OkAsync(ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PyroFetes.DTO.Sound.Response;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.Sound;
|
||||||
|
|
||||||
|
public class GetAllSoundsEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest<List<ReadSoundDto>>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Get("/sounds");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(CancellationToken ct)
|
||||||
|
{
|
||||||
|
var sounds = await pyroFetesDbContext.Sounds
|
||||||
|
.Select(s => new ReadSoundDto
|
||||||
|
{
|
||||||
|
Id = s.Id,
|
||||||
|
Name = s.Name,
|
||||||
|
Type = s.Type,
|
||||||
|
Artist = s.Artist,
|
||||||
|
Duration = s.Duration != null ? s.Duration.Value.ToString() : null,
|
||||||
|
Kind = s.Kind,
|
||||||
|
Format = s.Format,
|
||||||
|
CreationDate = s.CreationDate,
|
||||||
|
SoundCategoryId = s.SoundCategoryId.ToString()
|
||||||
|
})
|
||||||
|
.ToListAsync(ct);
|
||||||
|
|
||||||
|
await Send.OkAsync(sounds, ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PyroFetes.DTO.Sound.Request;
|
||||||
|
using PyroFetes.DTO.Sound.Response;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.Sound;
|
||||||
|
|
||||||
|
public class GetSoundEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint<IdSoundto, ReadSoundDto>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Get("/sounds/{Id}");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(IdSoundto req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
if (!req.Id.HasValue)
|
||||||
|
{
|
||||||
|
await Send.NotFoundAsync(ct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var sound = await pyroFetesDbContext.Sounds
|
||||||
|
.Where(s => s.Id == req.Id.Value)
|
||||||
|
.Select(s => new ReadSoundDto
|
||||||
|
{
|
||||||
|
Id = s.Id,
|
||||||
|
Name = s.Name,
|
||||||
|
Type = s.Type,
|
||||||
|
Artist = s.Artist,
|
||||||
|
Duration = s.Duration != null ? s.Duration.Value.ToString() : null,
|
||||||
|
Kind = s.Kind,
|
||||||
|
Format = s.Format,
|
||||||
|
CreationDate = s.CreationDate,
|
||||||
|
SoundCategoryId = s.SoundCategoryId.ToString()
|
||||||
|
})
|
||||||
|
.FirstOrDefaultAsync(ct);
|
||||||
|
|
||||||
|
if (sound is null)
|
||||||
|
{
|
||||||
|
await Send.NotFoundAsync(ct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await Send.OkAsync(sound, ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PyroFetes.DTO.Sound.Request;
|
||||||
|
using PyroFetes.DTO.Sound.Response;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.Sound;
|
||||||
|
|
||||||
|
public class UpdateSoundEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint<UpdateSoundDto, ReadSoundDto>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Put("/sounds/{Id}");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(UpdateSoundDto req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
if (!req.Id.HasValue)
|
||||||
|
{
|
||||||
|
await Send.NotFoundAsync(ct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var sound = await pyroFetesDbContext.Sounds
|
||||||
|
.FirstOrDefaultAsync(s => s.Id == req.Id.Value, ct);
|
||||||
|
|
||||||
|
if (sound is null)
|
||||||
|
{
|
||||||
|
await Send.NotFoundAsync(ct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sound.Name = req.Name ?? sound.Name;
|
||||||
|
sound.Type = req.Type ?? sound.Type;
|
||||||
|
sound.Artist = req.Artist ?? sound.Artist;
|
||||||
|
|
||||||
|
if (int.TryParse(req.Duration, out var duration))
|
||||||
|
{
|
||||||
|
sound.Duration = duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
sound.Kind = req.Kind ?? sound.Kind;
|
||||||
|
sound.Format = req.Format ?? sound.Format;
|
||||||
|
sound.CreationDate = req.CreationDate ?? sound.CreationDate;
|
||||||
|
|
||||||
|
if (int.TryParse(req.SoundCategoryId, out var categoryId))
|
||||||
|
{
|
||||||
|
sound.SoundCategoryId = categoryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
await pyroFetesDbContext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
|
var result = new ReadSoundDto
|
||||||
|
{
|
||||||
|
Id = sound.Id,
|
||||||
|
Name = sound.Name,
|
||||||
|
Type = sound.Type,
|
||||||
|
Artist = sound.Artist,
|
||||||
|
Duration = sound.Duration?.ToString(),
|
||||||
|
Kind = sound.Kind,
|
||||||
|
Format = sound.Format,
|
||||||
|
CreationDate = sound.CreationDate,
|
||||||
|
SoundCategoryId = sound.SoundCategoryId.ToString()
|
||||||
|
};
|
||||||
|
|
||||||
|
await Send.OkAsync(result, ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
using FastEndpoints;
|
||||||
|
using PyroFetes.DTO.SoundCategory.Request;
|
||||||
|
using PyroFetes.DTO.SoundCategory.Response;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.SoundCategory;
|
||||||
|
|
||||||
|
public class CreateSoundCategoryEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint<CreateSoundCategoryDto, ReadSoundCategoryDto>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Post("/soundcategorys");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(CreateSoundCategoryDto req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
var soundCategory = new PyroFetes.Models.SoundCategory
|
||||||
|
{
|
||||||
|
Name = req.Name,
|
||||||
|
};
|
||||||
|
|
||||||
|
pyroFetesDbContext.SoundCategories.Add(soundCategory);
|
||||||
|
await pyroFetesDbContext.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 PyroFetes.DTO.SoundCategory.Request;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.SoundCategory;
|
||||||
|
|
||||||
|
public class DeleteSoundCategoryEndpoint(PyroFetesDbContext pf3DbContext) : Endpoint<IdSoundCategoryDto>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Delete("/soundcategorys/{Id}");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(IdSoundCategoryDto req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
var soundCategory = await pf3DbContext.SoundCategories.FirstOrDefaultAsync(st => st.Id == req.Id, ct);
|
||||||
|
if (soundCategory is null)
|
||||||
|
{
|
||||||
|
await Send.NotFoundAsync(ct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pf3DbContext.SoundCategories.Remove(soundCategory);
|
||||||
|
await pf3DbContext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
|
await Send.OkAsync(ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PyroFetes.DTO.SoundCategory.Response;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.SoundCategory;
|
||||||
|
|
||||||
|
public class GetAllSoundCategorysEndpoint(PyroFetesDbContext pf3DbContext) : EndpointWithoutRequest<List<ReadSoundCategoryDto>>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Get("/soundcategorys");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(CancellationToken ct)
|
||||||
|
{
|
||||||
|
var soundCategorys = await pf3DbContext.SoundCategories.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 PyroFetes.DTO.SoundCategory.Request;
|
||||||
|
using PyroFetes.DTO.SoundCategory.Response;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.SoundCategory;
|
||||||
|
|
||||||
|
public class GetSoundCategoryEndpoint(PyroFetesDbContext pf3DbContext) : Endpoint<IdSoundCategoryDto, ReadSoundCategoryDto>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Get("/soundcategorys/{Id}");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(IdSoundCategoryDto req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
var soundCategory = await pf3DbContext.SoundCategories
|
||||||
|
.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 PyroFetes.DTO.SoundCategory.Request;
|
||||||
|
using PyroFetes.DTO.SoundCategory.Response;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.SoundCategory;
|
||||||
|
|
||||||
|
public class UpdateSoundCategoryEndpoint(PyroFetesDbContext pf3DbContext) : Endpoint<UpdateSoundCategoryDto, ReadSoundCategoryDto>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Patch("/soundcategorys/{Id}/name");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(UpdateSoundCategoryDto req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
var soundCategory = await pf3DbContext.SoundCategories.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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
using FastEndpoints;
|
||||||
|
using PyroFetes.DTO.SoundTimecode.Request;
|
||||||
|
using PyroFetes.DTO.SoundTimecode.Response;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.SoundTimecode;
|
||||||
|
|
||||||
|
public class CreateSoundTimecodeEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint<CreateSoundTimecodeDto, ReadSoundTimecodeDto>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Post("/soundtimecodes");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(CreateSoundTimecodeDto req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
var soundTimecode = new PyroFetes.Models.SoundTimecode
|
||||||
|
{
|
||||||
|
ShowId = req.ShowId,
|
||||||
|
SoundId = req.SoundId,
|
||||||
|
Start = req.Start,
|
||||||
|
End = req.End
|
||||||
|
};
|
||||||
|
|
||||||
|
pyroFetesDbContext.SoundTimecodes.Add(soundTimecode);
|
||||||
|
await pyroFetesDbContext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
|
var result = new ReadSoundTimecodeDto
|
||||||
|
{
|
||||||
|
ShowId = soundTimecode.ShowId,
|
||||||
|
SoundId = soundTimecode.SoundId,
|
||||||
|
Start = (int)soundTimecode.Start,
|
||||||
|
End = (int)soundTimecode.End
|
||||||
|
};
|
||||||
|
|
||||||
|
await Send.OkAsync(result, ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.SoundTimecode;
|
||||||
|
|
||||||
|
// DTO pour la route avec clé composite
|
||||||
|
public class DeleteSoundTimecodeRequest
|
||||||
|
{
|
||||||
|
public int ShowId { get; set; }
|
||||||
|
public int SoundId { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DeleteSoundTimecodeEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint<DeleteSoundTimecodeRequest>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Delete("/soundtimecodes/{ShowId}/{SoundId}");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(DeleteSoundTimecodeRequest req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
var soundTimecode = await pyroFetesDbContext.SoundTimecodes
|
||||||
|
.FirstOrDefaultAsync(st => st.ShowId == req.ShowId && st.SoundId == req.SoundId, ct);
|
||||||
|
|
||||||
|
if (soundTimecode is null)
|
||||||
|
{
|
||||||
|
await Send.NotFoundAsync(ct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pyroFetesDbContext.SoundTimecodes.Remove(soundTimecode);
|
||||||
|
await pyroFetesDbContext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
|
await Send.OkAsync(ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PyroFetes.DTO.SoundTimecode.Response;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.SoundTimecode;
|
||||||
|
|
||||||
|
public class GetAllSoundTimecodesEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest<List<ReadSoundTimecodeDto>>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Get("/soundtimecodes");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(CancellationToken ct)
|
||||||
|
{
|
||||||
|
var soundTimecodes = await pyroFetesDbContext.SoundTimecodes
|
||||||
|
.Select(st => new ReadSoundTimecodeDto
|
||||||
|
{
|
||||||
|
ShowId = st.ShowId,
|
||||||
|
SoundId = st.SoundId,
|
||||||
|
Start = (int)st.Start,
|
||||||
|
End = (int)st.End
|
||||||
|
})
|
||||||
|
.ToListAsync(ct);
|
||||||
|
|
||||||
|
await Send.OkAsync(soundTimecodes, ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PyroFetes.DTO.SoundTimecode.Response;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.SoundTimecode;
|
||||||
|
|
||||||
|
// DTO pour la route avec clé composite
|
||||||
|
public class GetSoundTimecodeRequest
|
||||||
|
{
|
||||||
|
public int ShowId { get; set; }
|
||||||
|
public int SoundId { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GetSoundTimecodeEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint<GetSoundTimecodeRequest, ReadSoundTimecodeDto>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Get("/soundtimecodes/{ShowId}/{SoundId}");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(GetSoundTimecodeRequest req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
var soundTimecode = await pyroFetesDbContext.SoundTimecodes
|
||||||
|
.Where(st => st.ShowId == req.ShowId && st.SoundId == req.SoundId)
|
||||||
|
.Select(st => new ReadSoundTimecodeDto
|
||||||
|
{
|
||||||
|
ShowId = st.ShowId,
|
||||||
|
SoundId = st.SoundId,
|
||||||
|
Start = (int)st.Start,
|
||||||
|
End = (int)st.End
|
||||||
|
})
|
||||||
|
.FirstOrDefaultAsync(ct);
|
||||||
|
|
||||||
|
if (soundTimecode is null)
|
||||||
|
{
|
||||||
|
await Send.NotFoundAsync(ct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await Send.OkAsync(soundTimecode, ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PyroFetes.DTO.SoundTimecode.Request;
|
||||||
|
using PyroFetes.DTO.SoundTimecode.Response;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.SoundTimecode;
|
||||||
|
|
||||||
|
// DTO pour la route avec clé composite
|
||||||
|
public class UpdateSoundTimecodeRequest
|
||||||
|
{
|
||||||
|
public int ShowId { get; set; }
|
||||||
|
public int SoundId { get; set; }
|
||||||
|
public int Start { get; set; }
|
||||||
|
public int End { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class UpdateSoundTimecodeEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint<UpdateSoundTimecodeRequest, ReadSoundTimecodeDto>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Put("/soundtimecodes/{ShowId}/{SoundId}");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(UpdateSoundTimecodeRequest req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
var soundTimecode = await pyroFetesDbContext.SoundTimecodes
|
||||||
|
.FirstOrDefaultAsync(st => st.ShowId == req.ShowId && st.SoundId == req.SoundId, ct);
|
||||||
|
|
||||||
|
if (soundTimecode is null)
|
||||||
|
{
|
||||||
|
await Send.NotFoundAsync(ct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
soundTimecode.Start = req.Start;
|
||||||
|
soundTimecode.End = req.End;
|
||||||
|
|
||||||
|
await pyroFetesDbContext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
|
var result = new ReadSoundTimecodeDto
|
||||||
|
{
|
||||||
|
ShowId = soundTimecode.ShowId,
|
||||||
|
SoundId = soundTimecode.SoundId,
|
||||||
|
Start = (int)soundTimecode.Start,
|
||||||
|
End = (int)soundTimecode.End
|
||||||
|
};
|
||||||
|
|
||||||
|
await Send.OkAsync(result, ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
using FastEndpoints;
|
||||||
|
using PyroFetes.DTO.Staff.Request;
|
||||||
|
using PyroFetes.DTO.Staff.Response;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.Staff;
|
||||||
|
|
||||||
|
public class CreateStaffEndpoint(PyroFetesDbContext pf3DbContext):Endpoint<CreateStaffDto, ReadStaffDto>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Post("/staff");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(CreateStaffDto req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
var staff = new PyroFetes.Models.Staff
|
||||||
|
{
|
||||||
|
FirstName = req.FirstName,
|
||||||
|
LastName = req.LastName,
|
||||||
|
Profession = req.Profession,
|
||||||
|
Email = req.Email,
|
||||||
|
F4T2NumberApproval = req.F4T2NumberApproval,
|
||||||
|
F4T2ExpirationDate = req.F4T2ExpirationDate
|
||||||
|
};
|
||||||
|
|
||||||
|
pf3DbContext.Staffs.Add(staff);
|
||||||
|
await pf3DbContext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
|
var result = new ReadStaffDto()
|
||||||
|
{
|
||||||
|
Id = staff.Id,
|
||||||
|
FirstName = staff.FirstName,
|
||||||
|
LastName = staff.LastName,
|
||||||
|
Profession = staff.Profession,
|
||||||
|
Email = staff.Email,
|
||||||
|
F4T2NumberApproval = staff.F4T2NumberApproval,
|
||||||
|
F4T2ExpirationDate = staff.F4T2ExpirationDate
|
||||||
|
};
|
||||||
|
|
||||||
|
await Send.OkAsync(result, ct);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PyroFetes.DTO.Staff.Request;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.Staff;
|
||||||
|
|
||||||
|
public class DeleteStaffEndpoint(PyroFetesDbContext pf3DbContext) : Endpoint<IdStaffDto>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Delete("/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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PyroFetes.DTO.Staff.Response;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.Staff;
|
||||||
|
|
||||||
|
public class GetAllStaffEndpoint(PyroFetesDbContext pf3DbContext) : EndpointWithoutRequest<List<ReadStaffDto>>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Get("/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,
|
||||||
|
F4T2NumberApproval = s.F4T2NumberApproval,
|
||||||
|
F4T2ExpirationDate = s.F4T2ExpirationDate
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
await Send.OkAsync(result, ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PyroFetes.DTO.Staff.Request;
|
||||||
|
using PyroFetes.DTO.Staff.Response;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.Staff;
|
||||||
|
|
||||||
|
public class GetStaffEndpoint(PyroFetesDbContext pf3DbContext) : Endpoint<IdStaffDto, ReadStaffDto>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Get("/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,
|
||||||
|
F4T2NumberApproval = s.F4T2NumberApproval,
|
||||||
|
F4T2ExpirationDate = s.F4T2ExpirationDate
|
||||||
|
})
|
||||||
|
.FirstOrDefaultAsync(ct);
|
||||||
|
|
||||||
|
if (staff is null)
|
||||||
|
{
|
||||||
|
await Send.NotFoundAsync(ct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await Send.OkAsync(staff, ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PyroFetes.DTO.Staff.Request;
|
||||||
|
using PyroFetes.DTO.Staff.Response;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.Staff;
|
||||||
|
|
||||||
|
public class UpdateStaffEndpoint(PyroFetesDbContext pf3DbContext) : Endpoint<UpdateStaffDto, ReadStaffDto>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Put("/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.FirstName;
|
||||||
|
staff.LastName = req.LastName ?? staff.LastName;
|
||||||
|
staff.Profession = req.Profession ?? staff.Profession;
|
||||||
|
staff.Email = req.Email ?? staff.Email;
|
||||||
|
staff.F4T2NumberApproval = req.F4T2NumberApproval ?? staff.F4T2NumberApproval;
|
||||||
|
if (req.F4T2ExpirationDate.HasValue)
|
||||||
|
staff.F4T2ExpirationDate = req.F4T2ExpirationDate.Value;
|
||||||
|
|
||||||
|
await pf3DbContext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
|
var result = new ReadStaffDto
|
||||||
|
{
|
||||||
|
Id = staff.Id,
|
||||||
|
FirstName = staff.FirstName,
|
||||||
|
LastName = staff.LastName,
|
||||||
|
Profession = staff.Profession,
|
||||||
|
Email = staff.Email,
|
||||||
|
F4T2NumberApproval = staff.F4T2NumberApproval,
|
||||||
|
F4T2ExpirationDate = staff.F4T2ExpirationDate
|
||||||
|
};
|
||||||
|
|
||||||
|
await Send.OkAsync(result, ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
using FastEndpoints;
|
||||||
|
using PyroFetes.DTO.Truck.Request;
|
||||||
|
using PyroFetes.DTO.Truck.Response;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.Truck;
|
||||||
|
|
||||||
|
public class CreateTruckEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint<CreateTruckDto, ReadTruckDto>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Post("/trucks");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(CreateTruckDto req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
var truck = new PyroFetes.Models.Truck
|
||||||
|
{
|
||||||
|
Type = req.Type ?? string.Empty,
|
||||||
|
MaxExplosiveCapacity = req.MaxExplosiveCapacity,
|
||||||
|
Sizes = req.Sizes,
|
||||||
|
Status = req.Status
|
||||||
|
};
|
||||||
|
|
||||||
|
pyroFetesDbContext.Trucks.Add(truck);
|
||||||
|
await pyroFetesDbContext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
|
// Ajouter la relation ShowTruck si ShowId est fourni
|
||||||
|
if (req.ShowId.HasValue && req.ShowId.Value != 0)
|
||||||
|
{
|
||||||
|
var showTruck = new PyroFetes.Models.ShowTruck
|
||||||
|
{
|
||||||
|
TruckId = truck.Id,
|
||||||
|
ShowId = req.ShowId.Value
|
||||||
|
};
|
||||||
|
pyroFetesDbContext.ShowTrucks.Add(showTruck);
|
||||||
|
await pyroFetesDbContext.SaveChangesAsync(ct);
|
||||||
|
}
|
||||||
|
|
||||||
|
var result = new ReadTruckDto
|
||||||
|
{
|
||||||
|
Id = truck.Id,
|
||||||
|
Type = truck.Type,
|
||||||
|
MaxExplosiveCapacity = truck.MaxExplosiveCapacity,
|
||||||
|
Sizes = truck.Sizes,
|
||||||
|
Statut = truck.Status,
|
||||||
|
ShowId = req.ShowId
|
||||||
|
};
|
||||||
|
|
||||||
|
await Send.OkAsync(result, ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PyroFetes.DTO.Truck.Request;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.Truck;
|
||||||
|
|
||||||
|
public class DeleteTruckEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint<IdTruckDto>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Delete("/trucks/{Id}");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(IdTruckDto req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
if (!req.Id.HasValue)
|
||||||
|
{
|
||||||
|
await Send.NotFoundAsync(ct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var truck = await pyroFetesDbContext.Trucks
|
||||||
|
.Include(t => t.ShowTrucks)
|
||||||
|
.FirstOrDefaultAsync(t => t.Id == req.Id.Value, ct);
|
||||||
|
|
||||||
|
if (truck is null)
|
||||||
|
{
|
||||||
|
await Send.NotFoundAsync(ct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Supprimer les relations ShowTruck associées
|
||||||
|
if (truck.ShowTrucks != null && truck.ShowTrucks.Any())
|
||||||
|
{
|
||||||
|
pyroFetesDbContext.ShowTrucks.RemoveRange(truck.ShowTrucks);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Supprimer le truck
|
||||||
|
pyroFetesDbContext.Trucks.Remove(truck);
|
||||||
|
await pyroFetesDbContext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
|
await Send.OkAsync(ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PyroFetes.DTO.Truck.Response;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.Truck;
|
||||||
|
|
||||||
|
public class GetAllTrucksEndpoint(PyroFetesDbContext pyroFetesDbContext) : EndpointWithoutRequest<List<ReadTruckDto>>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Get("/trucks");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(CancellationToken ct)
|
||||||
|
{
|
||||||
|
var trucks = await pyroFetesDbContext.Trucks
|
||||||
|
.Include(t => t.ShowTrucks)
|
||||||
|
.Select(t => new ReadTruckDto
|
||||||
|
{
|
||||||
|
Id = t.Id,
|
||||||
|
Type = t.Type,
|
||||||
|
MaxExplosiveCapacity = t.MaxExplosiveCapacity,
|
||||||
|
Sizes = t.Sizes,
|
||||||
|
Statut = t.Status,
|
||||||
|
ShowId = t.ShowTrucks!.FirstOrDefault() != null ? t.ShowTrucks.FirstOrDefault()!.ShowId : null
|
||||||
|
})
|
||||||
|
.ToListAsync(ct);
|
||||||
|
|
||||||
|
await Send.OkAsync(trucks, ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PyroFetes.DTO.Truck.Request;
|
||||||
|
using PyroFetes.DTO.Truck.Response;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.Truck;
|
||||||
|
|
||||||
|
public class GetTruckEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint<IdTruckDto, ReadTruckDto>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Get("/trucks/{Id}");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(IdTruckDto req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
if (!req.Id.HasValue)
|
||||||
|
{
|
||||||
|
await Send.NotFoundAsync(ct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var truck = await pyroFetesDbContext.Trucks
|
||||||
|
.Where(t => t.Id == req.Id.Value)
|
||||||
|
.Select(t => new ReadTruckDto
|
||||||
|
{
|
||||||
|
Id = t.Id,
|
||||||
|
Type = t.Type,
|
||||||
|
MaxExplosiveCapacity = t.MaxExplosiveCapacity,
|
||||||
|
Sizes = t.Sizes,
|
||||||
|
Statut = t.Status,
|
||||||
|
ShowId = t.ShowTrucks!.FirstOrDefault() != null ? t.ShowTrucks.FirstOrDefault()!.ShowId : null
|
||||||
|
})
|
||||||
|
.FirstOrDefaultAsync(ct);
|
||||||
|
|
||||||
|
if (truck is null)
|
||||||
|
{
|
||||||
|
await Send.NotFoundAsync(ct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await Send.OkAsync(truck, ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PyroFetes.DTO.Truck.Request;
|
||||||
|
using PyroFetes.DTO.Truck.Response;
|
||||||
|
|
||||||
|
namespace PyroFetes.Endpoints.Truck;
|
||||||
|
|
||||||
|
public class UpdateTruckEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint<UpdateTruckDto, ReadTruckDto>
|
||||||
|
{
|
||||||
|
public override void Configure()
|
||||||
|
{
|
||||||
|
Put("/trucks/{Id}");
|
||||||
|
AllowAnonymous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task HandleAsync(UpdateTruckDto req, CancellationToken ct)
|
||||||
|
{
|
||||||
|
if (!req.Id.HasValue)
|
||||||
|
{
|
||||||
|
await Send.NotFoundAsync(ct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var truck = await pyroFetesDbContext.Trucks
|
||||||
|
.Include(t => t.ShowTrucks)
|
||||||
|
.FirstOrDefaultAsync(t => t.Id == req.Id.Value, ct);
|
||||||
|
|
||||||
|
if (truck is null)
|
||||||
|
{
|
||||||
|
await Send.NotFoundAsync(ct);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mise à jour des propriétés du truck
|
||||||
|
truck.Type = req.Type ?? truck.Type;
|
||||||
|
if (double.TryParse(req.MaxExplosiveCapacity, out var capacity))
|
||||||
|
{
|
||||||
|
truck.MaxExplosiveCapacity = capacity;
|
||||||
|
}
|
||||||
|
truck.Sizes = req.Sizes ?? truck.Sizes;
|
||||||
|
truck.Status = req.Statut ?? truck.Status;
|
||||||
|
|
||||||
|
// Gérer la relation ShowTruck
|
||||||
|
if (req.ShowId.HasValue)
|
||||||
|
{
|
||||||
|
// Supprimer l'ancienne relation
|
||||||
|
if (truck.ShowTrucks != null && truck.ShowTrucks.Any())
|
||||||
|
{
|
||||||
|
var existingShowTrucks = truck.ShowTrucks.ToList();
|
||||||
|
foreach (var st in existingShowTrucks)
|
||||||
|
{
|
||||||
|
pyroFetesDbContext.ShowTrucks.Remove(st);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ajouter la nouvelle relation si ShowId n'est pas 0
|
||||||
|
if (req.ShowId.Value != 0)
|
||||||
|
{
|
||||||
|
var newShowTruck = new PyroFetes.Models.ShowTruck
|
||||||
|
{
|
||||||
|
TruckId = truck.Id,
|
||||||
|
ShowId = req.ShowId.Value
|
||||||
|
};
|
||||||
|
pyroFetesDbContext.ShowTrucks.Add(newShowTruck);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await pyroFetesDbContext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
|
var result = new ReadTruckDto
|
||||||
|
{
|
||||||
|
Id = truck.Id,
|
||||||
|
Type = truck.Type,
|
||||||
|
MaxExplosiveCapacity = truck.MaxExplosiveCapacity,
|
||||||
|
Sizes = truck.Sizes,
|
||||||
|
Statut = truck.Status,
|
||||||
|
ShowId = req.ShowId
|
||||||
|
};
|
||||||
|
|
||||||
|
await Send.OkAsync(result, ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace PyroFetes.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class MakeCityIdNullable : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Shows_Cities_CityId",
|
||||||
|
table: "Shows");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<int>(
|
||||||
|
name: "CityId",
|
||||||
|
table: "Shows",
|
||||||
|
type: "int",
|
||||||
|
nullable: true,
|
||||||
|
oldClrType: typeof(int),
|
||||||
|
oldType: "int");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Shows_Cities_CityId",
|
||||||
|
table: "Shows",
|
||||||
|
column: "CityId",
|
||||||
|
principalTable: "Cities",
|
||||||
|
principalColumn: "Id");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Shows_Cities_CityId",
|
||||||
|
table: "Shows");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<int>(
|
||||||
|
name: "CityId",
|
||||||
|
table: "Shows",
|
||||||
|
type: "int",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0,
|
||||||
|
oldClrType: typeof(int),
|
||||||
|
oldType: "int",
|
||||||
|
oldNullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Shows_Cities_CityId",
|
||||||
|
table: "Shows",
|
||||||
|
column: "CityId",
|
||||||
|
principalTable: "Cities",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -813,7 +813,7 @@ namespace PyroFetes.Migrations
|
|||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
b.Property<int>("CityId")
|
b.Property<int?>("CityId")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<DateOnly?>("Date")
|
b.Property<DateOnly?>("Date")
|
||||||
@@ -1594,8 +1594,7 @@ namespace PyroFetes.Migrations
|
|||||||
b.HasOne("PyroFetes.Models.City", "City")
|
b.HasOne("PyroFetes.Models.City", "City")
|
||||||
.WithMany("Shows")
|
.WithMany("Shows")
|
||||||
.HasForeignKey("CityId")
|
.HasForeignKey("CityId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.ClientSetNull);
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("City");
|
b.Navigation("City");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ public class Show
|
|||||||
// Link (path/URL/file name) to the pyrotechnic implementation plan
|
// Link (path/URL/file name) to the pyrotechnic implementation plan
|
||||||
[Required, MaxLength(500)] public string? PyrotechnicImplementationPlan { get; set; }
|
[Required, MaxLength(500)] public string? PyrotechnicImplementationPlan { get; set; }
|
||||||
|
|
||||||
[Required] public int CityId { get; set; }
|
public int? CityId { get; set; }
|
||||||
public City? City { get; set; }
|
public City? City { get; set; }
|
||||||
|
|
||||||
public List<ShowStaff>? ShowStaffs { get; set; }
|
public List<ShowStaff>? ShowStaffs { get; set; }
|
||||||
|
|||||||
+31
-8
@@ -1,19 +1,42 @@
|
|||||||
|
using FastEndpoints;
|
||||||
|
using FastEndpoints.Swagger;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PyroFetes;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
// Add services to the container.
|
builder.Services.AddDbContext<PyroFetesDbContext>(options =>
|
||||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection")));
|
||||||
builder.Services.AddEndpointsApiExplorer();
|
|
||||||
builder.Services.AddSwaggerGen();
|
builder.Services.AddFastEndpoints();
|
||||||
|
builder.Services.SwaggerDocument();
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
using (var scope = app.Services.CreateScope())
|
||||||
|
{
|
||||||
|
var db = scope.ServiceProvider.GetRequiredService<PyroFetesDbContext>();
|
||||||
|
db.Database.ExecuteSqlRaw("""
|
||||||
|
IF EXISTS (
|
||||||
|
SELECT 1 FROM sys.foreign_keys
|
||||||
|
WHERE name = 'FK_Shows_Cities_CityId' AND parent_object_id = OBJECT_ID('Shows')
|
||||||
|
)
|
||||||
|
ALTER TABLE Shows DROP CONSTRAINT FK_Shows_Cities_CityId
|
||||||
|
""");
|
||||||
|
db.Database.ExecuteSqlRaw("""
|
||||||
|
IF COL_LENGTH('Shows', 'CityId') IS NOT NULL
|
||||||
|
AND COLUMNPROPERTY(OBJECT_ID('Shows'), 'CityId', 'AllowsNull') = 0
|
||||||
|
ALTER TABLE Shows ALTER COLUMN CityId INT NULL
|
||||||
|
""");
|
||||||
|
}
|
||||||
|
|
||||||
if (app.Environment.IsDevelopment())
|
if (app.Environment.IsDevelopment())
|
||||||
{
|
{
|
||||||
app.UseSwagger();
|
app.UseSwaggerGen();
|
||||||
app.UseSwaggerUI();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
|
app.UseFastEndpoints();
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
|
|
||||||
@@ -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">
|
||||||
@@ -17,4 +19,11 @@
|
|||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2"/>
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Endpoints\Show\" />
|
||||||
|
<Folder Include="Endpoints\SoundTimecode\" />
|
||||||
|
<Folder Include="Endpoints\Sound\" />
|
||||||
|
<Folder Include="Endpoints\Truck\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using ServiceProvider = PyroFetes.Models.ServiceProvider;
|
|||||||
|
|
||||||
namespace PyroFetes;
|
namespace PyroFetes;
|
||||||
|
|
||||||
public class PyroFetesDbContext : DbContext
|
public class PyroFetesDbContext(DbContextOptions<PyroFetesDbContext> options) : DbContext(options)
|
||||||
{
|
{
|
||||||
// Entities
|
// Entities
|
||||||
public DbSet<Availability> Availabilities { get; set; }
|
public DbSet<Availability> Availabilities { get; set; }
|
||||||
@@ -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; }
|
||||||
|
|||||||
@@ -5,5 +5,8 @@
|
|||||||
"Microsoft.AspNetCore": "Warning"
|
"Microsoft.AspNetCore": "Warning"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*"
|
"AllowedHosts": "*",
|
||||||
|
"ConnectionStrings": {
|
||||||
|
"DefaultConnection": "Server=romaric-thibault.fr;Database=PyroFetes;Trusted_Connection=True;TrustServerCertificate=True;"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
# Gestionnaire de Stocks et Commandes
|
||||||
|
|
||||||
|
Cette application web permet de **suivre les stocks**, **automatiser les commandes fournisseurs** et **gérer le cycle complet d’approvisionnement**.
|
||||||
|
Elle est conçue pour simplifier le travail des entreprises en offrant une vue en temps réel sur les produits, leurs fournisseurs et l’état des livraisons.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ✨ Fonctionnalités principales
|
||||||
|
|
||||||
|
### 1️⃣ Suivi et réapprovisionnement des stocks
|
||||||
|
- Définissez un **niveau minimal de stock** pour chaque produit.
|
||||||
|
- Surveillez les **niveaux en temps réel** grâce à une interface claire.
|
||||||
|
- Lorsqu’un produit atteint ou descend sous son seuil minimal, le système **génère automatiquement un bon de commande** pour le réapprovisionner.
|
||||||
|
|
||||||
|
### 2️⃣ Gestion des fournisseurs
|
||||||
|
- Enregistrez les informations complètes des fournisseurs : nom, adresse, coordonnées, produits fournis, délais de livraison.
|
||||||
|
- **Associez un ou plusieurs fournisseurs** à chaque produit.
|
||||||
|
- Lorsqu’un bon de commande est créé, le système **propose automatiquement les fournisseurs appropriés**.
|
||||||
|
|
||||||
|
### 3️⃣ Devis et bons de commande
|
||||||
|
- Créez des **devis personnalisés** : sélection des produits, quantités, prix, ajout d’un logo, message ou conditions de vente.
|
||||||
|
- **Imprimez ou exportez** vos devis au format PDF.
|
||||||
|
- Générez des **bons de commande** en quelques clics, avec personnalisation (logo, conditions d’achat) et exportation en PDF.
|
||||||
|
|
||||||
|
### 4️⃣ Suivi des livraisons
|
||||||
|
- **Transformez un bon de commande en bon de livraison** dès l’expédition des produits par le fournisseur.
|
||||||
|
- Enregistrez toutes les informations importantes : date d’expédition, transporteur, numéro de suivi, date prévue et date effective de livraison.
|
||||||
|
- Recevez des **alertes en cas de retard**.
|
||||||
|
- Gérez la **réception des produits** et vérifiez leur conformité.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🗂️ Livrables prévus
|
||||||
|
- **Modèle de données** : diagramme de classes commun à tous les groupes.
|
||||||
|
- **Interface utilisateur** : maquettes ou prototypes interactifs.
|
||||||
|
- **Code source commenté** pour une meilleure compréhension.
|
||||||
|
- **Documentation technique** : description des fonctionnalités, architecture de l’application et API.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 👥 Équipe
|
||||||
|
- **Mathys**
|
||||||
|
- **Enzo**
|
||||||
|
- **Cristiano**
|
||||||
|
- **Arsène**
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🚀 Objectif
|
||||||
|
Fournir un outil complet pour automatiser la gestion des stocks et des commandes, réduisant les erreurs humaines, améliorant le suivi des livraisons et facilitant la communication avec les fournisseurs.
|
||||||
Reference in New Issue
Block a user