diff --git a/PyroFetes/DTO/Supplier/Response/GetSupplierDto.cs b/PyroFetes/DTO/Supplier/Response/GetSupplierDto.cs index 1fc9a60..dbd2ffb 100644 --- a/PyroFetes/DTO/Supplier/Response/GetSupplierDto.cs +++ b/PyroFetes/DTO/Supplier/Response/GetSupplierDto.cs @@ -1,3 +1,5 @@ +using PyroFetes.DTO.Product.Response; + namespace PyroFetes.DTO.Supplier.Response; public class GetSupplierDto @@ -10,4 +12,5 @@ public class GetSupplierDto public string? ZipCode { get; set; } public string? City { get; set; } public int DeliveryDelay { get; set; } + public List? Products { get; set; } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/Users/CreateUserEndpoint.cs b/PyroFetes/Endpoints/Users/CreateUserEndpoint.cs index 1a014d9..73c557b 100644 --- a/PyroFetes/Endpoints/Users/CreateUserEndpoint.cs +++ b/PyroFetes/Endpoints/Users/CreateUserEndpoint.cs @@ -4,6 +4,7 @@ using PyroFetes.DTO.User.Request; using PyroFetes.DTO.User.Response; using PyroFetes.Models; using PyroFetes.Repositories; +using PyroFetes.Specifications.Users; namespace PyroFetes.Endpoints.Users; @@ -19,6 +20,14 @@ public class CreateUserEndpoint( public override async Task HandleAsync(CreateUserDto req, CancellationToken ct) { + User? ckeckName = await usersRepository.FirstOrDefaultAsync(new GetUserByNameSpec(req.Name!), ct); + + if (ckeckName != null) + { + await Send.StringAsync("Ce nom d'utilisateur existe déjà.",409, cancellation: ct); + return; + } + string? salt = new Password().IncludeLowercase().IncludeUppercase().IncludeNumeric().LengthRequired(24).Next(); User user = new User() diff --git a/PyroFetes/Endpoints/Users/UpdateUserEndpoint.cs b/PyroFetes/Endpoints/Users/UpdateUserEndpoint.cs index b50439d..46eac23 100644 --- a/PyroFetes/Endpoints/Users/UpdateUserEndpoint.cs +++ b/PyroFetes/Endpoints/Users/UpdateUserEndpoint.cs @@ -30,7 +30,7 @@ public class UpdateUserEndpoint( return; } - if (ckeckName != null) + if (ckeckName != null && ckeckName.Id != user.Id) { await Send.StringAsync("Ce nom d'utilisateur existe déjà.",409, cancellation: ct); return;