diff --git a/.idea/.idea.BookHive/.idea/workspace.xml b/.idea/.idea.BookHive/.idea/workspace.xml index d4cc24f..f6a3110 100644 --- a/.idea/.idea.BookHive/.idea/workspace.xml +++ b/.idea/.idea.BookHive/.idea/workspace.xml @@ -6,23 +6,25 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + @@ -186,7 +196,8 @@ - diff --git a/BookHive/Program.cs b/BookHive/Program.cs index 24725dd..5c611ea 100644 --- a/BookHive/Program.cs +++ b/BookHive/Program.cs @@ -63,7 +63,4 @@ app.UseAuthentication() // app.UseCors(); -app.Services.GetRequiredService().Database.EnsureDeleted(); -app.Services.GetRequiredService().Database.EnsureCreated(); - app.Run(); \ No newline at end of file diff --git a/BookHive/Specifications/Books/GetBookByIdSpec.cs b/BookHive/Specifications/Books/GetBookByIdSpec.cs index d98b222..6053212 100644 --- a/BookHive/Specifications/Books/GetBookByIdSpec.cs +++ b/BookHive/Specifications/Books/GetBookByIdSpec.cs @@ -8,6 +8,7 @@ public class GetBookByIdSpec : SingleResultSpecification public GetBookByIdSpec(int bookId) { Query + .Include(x => x.Author) .Where(x => x.Id == bookId); } } \ No newline at end of file diff --git a/BookHive/Validators/Books/CreateBookDtoValidator.cs b/BookHive/Validators/Books/CreateBookDtoValidator.cs index 92dcdeb..8cc4dd7 100644 --- a/BookHive/Validators/Books/CreateBookDtoValidator.cs +++ b/BookHive/Validators/Books/CreateBookDtoValidator.cs @@ -14,9 +14,9 @@ public class CreateBookDtoValidator : Validator .WithMessage("Le titre ne peut pas dépasser 200 caractères."); RuleFor(x => x.Isbn) - .NotEmpty().WithMessage("L’ISBN est obligatoire.") - .Matches(@"^\d{13}$") - .WithMessage("L’ISBN doit contenir exactement 13 chiffres."); + .NotEmpty() + .WithMessage("L’ISBN est obligatoire.")! + .IsValidIsbn13(); RuleFor(x => x.PageCount) .GreaterThan(0) diff --git a/BookHive/Validators/Loans/CreateLoanDtoValidator.cs b/BookHive/Validators/Loans/CreateLoanDtoValidator.cs index 7cfd56a..e3970b7 100644 --- a/BookHive/Validators/Loans/CreateLoanDtoValidator.cs +++ b/BookHive/Validators/Loans/CreateLoanDtoValidator.cs @@ -26,6 +26,17 @@ public class CreateLoanDtoValidator : Validator .GreaterThan(d => d.LoanDate) .WithMessage("Due date must be in the future.") .Must((loan, dueDate) => dueDate <= loan.LoanDate.AddDays(30)) - .WithMessage("Due date must be in the future.");; + .WithMessage("Due date must be in the future."); + + RuleFor(x => x.DueDate) + .Must((dto, dueDate) => + { + var dayOfWeek = dto.LoanDate.DayOfWeek; + var isWeekend = dayOfWeek == DayOfWeek.Saturday + || dayOfWeek == DayOfWeek.Sunday; + var maxDays = isWeekend ? 14 : 30; + return dueDate <= dto.LoanDate.AddDays(maxDays); + }) + .WithMessage("La durée max est de 14j (week-end) ou 30j (semaine)."); } } \ No newline at end of file diff --git a/BookHive/Validators/Reviews/CreateReviewDtoValidator.cs b/BookHive/Validators/Reviews/CreateReviewDtoValidator.cs index 4a2caca..58abaf6 100644 --- a/BookHive/Validators/Reviews/CreateReviewDtoValidator.cs +++ b/BookHive/Validators/Reviews/CreateReviewDtoValidator.cs @@ -18,7 +18,7 @@ public class CreateReviewDtoValidator : Validator RuleFor(x => x.Rating) .InclusiveBetween(1, 5) - .WithMessage("Rating must be between 1 and 5."); + .WithMessage(x => $"La note {x.Rating} est invalide. Elle doit être comprise entre 1 et 5."); When(x => x.Comment is not null, () => { diff --git a/BookHive/Validators/Reviews/UpdateReviewDtoValidator.cs b/BookHive/Validators/Reviews/UpdateReviewDtoValidator.cs index c1d0980..ab771b2 100644 --- a/BookHive/Validators/Reviews/UpdateReviewDtoValidator.cs +++ b/BookHive/Validators/Reviews/UpdateReviewDtoValidator.cs @@ -22,7 +22,7 @@ public class UpdateReviewDtoValidator : Validator RuleFor(x => x.Rating) .InclusiveBetween(1, 5) - .WithMessage("Rating must be between 1 and 5."); + .WithMessage(x => $"La note {x.Rating} est invalide. Elle doit être comprise entre 1 et 5."); When(x => x.Comment is not null, () => { diff --git a/BookHive/bin/Debug/net10.0/BookHive.dll b/BookHive/bin/Debug/net10.0/BookHive.dll index b133649..7201d05 100644 Binary files a/BookHive/bin/Debug/net10.0/BookHive.dll and b/BookHive/bin/Debug/net10.0/BookHive.dll differ diff --git a/BookHive/bin/Debug/net10.0/BookHive.pdb b/BookHive/bin/Debug/net10.0/BookHive.pdb index ce56054..8f5f40a 100644 Binary files a/BookHive/bin/Debug/net10.0/BookHive.pdb and b/BookHive/bin/Debug/net10.0/BookHive.pdb differ diff --git a/BookHive/obj/Debug/net10.0/BookHive.AssemblyInfo.cs b/BookHive/obj/Debug/net10.0/BookHive.AssemblyInfo.cs index 8c000c4..ca95787 100644 --- a/BookHive/obj/Debug/net10.0/BookHive.AssemblyInfo.cs +++ b/BookHive/obj/Debug/net10.0/BookHive.AssemblyInfo.cs @@ -13,7 +13,7 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("BookHive")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+ecdabab5a1a621c003643d8f0f2e492d314951f9")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+9f858df5f8559ef4eece66d288194275a0509245")] [assembly: System.Reflection.AssemblyProductAttribute("BookHive")] [assembly: System.Reflection.AssemblyTitleAttribute("BookHive")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/BookHive/obj/Debug/net10.0/BookHive.AssemblyInfoInputs.cache b/BookHive/obj/Debug/net10.0/BookHive.AssemblyInfoInputs.cache index f33ae26..7a76e2c 100644 --- a/BookHive/obj/Debug/net10.0/BookHive.AssemblyInfoInputs.cache +++ b/BookHive/obj/Debug/net10.0/BookHive.AssemblyInfoInputs.cache @@ -1 +1 @@ -38e3040d9641db39778141a07f9c125f563b85c555e95be9b8385c95c14acd96 +24c20bc00ebed273ed8d88d70e9db8fba99e16f4c11f44fa290911d9e2a0ca7d diff --git a/BookHive/obj/Debug/net10.0/BookHive.csproj.CoreCompileInputs.cache b/BookHive/obj/Debug/net10.0/BookHive.csproj.CoreCompileInputs.cache index 5947d38..eb05b2e 100644 --- a/BookHive/obj/Debug/net10.0/BookHive.csproj.CoreCompileInputs.cache +++ b/BookHive/obj/Debug/net10.0/BookHive.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -41fc3b734d4bc6835927453b9f4d7cdd11e742d0714a8d542d23004e43ece95a +83126e6bfb83bdfd52cfec65d256c75a3ab035c366b329c9b517e33f5e1849d1 diff --git a/BookHive/obj/Debug/net10.0/BookHive.dll b/BookHive/obj/Debug/net10.0/BookHive.dll index b133649..7201d05 100644 Binary files a/BookHive/obj/Debug/net10.0/BookHive.dll and b/BookHive/obj/Debug/net10.0/BookHive.dll differ diff --git a/BookHive/obj/Debug/net10.0/BookHive.pdb b/BookHive/obj/Debug/net10.0/BookHive.pdb index ce56054..8f5f40a 100644 Binary files a/BookHive/obj/Debug/net10.0/BookHive.pdb and b/BookHive/obj/Debug/net10.0/BookHive.pdb differ diff --git a/BookHive/obj/Debug/net10.0/ref/BookHive.dll b/BookHive/obj/Debug/net10.0/ref/BookHive.dll index 2082f1f..e58d403 100644 Binary files a/BookHive/obj/Debug/net10.0/ref/BookHive.dll and b/BookHive/obj/Debug/net10.0/ref/BookHive.dll differ diff --git a/BookHive/obj/Debug/net10.0/refint/BookHive.dll b/BookHive/obj/Debug/net10.0/refint/BookHive.dll index 2082f1f..e58d403 100644 Binary files a/BookHive/obj/Debug/net10.0/refint/BookHive.dll and b/BookHive/obj/Debug/net10.0/refint/BookHive.dll differ diff --git a/BookHive/obj/Debug/net10.0/rjsmcshtml.dswa.cache.json b/BookHive/obj/Debug/net10.0/rjsmcshtml.dswa.cache.json index 152c9cf..5574a71 100644 --- a/BookHive/obj/Debug/net10.0/rjsmcshtml.dswa.cache.json +++ b/BookHive/obj/Debug/net10.0/rjsmcshtml.dswa.cache.json @@ -1 +1 @@ -{"GlobalPropertiesHash":"GuRprL5mC7hc0CG8FgEPpIWKx/Dfl1Jhxvhk8sWxBEQ=","FingerprintPatternsHash":"gq3WsqcKBUGTSNle7RKKyXRIwh7M8ccEqOqYvIzoM04=","PropertyOverridesHash":"8ZRc1sGeVrPBx4lD717BgRaQekyh78QKV9SKsdt638U=","InputHashes":["kIO\u002BgVQX72rEP/AM8N4erO8boVd0NQ5bkxTtUbSKS9I=","Uf8MX/\u002BVloY39fAvymRXdZ4qt/FRES4KRvClr57fYDU=","lfZuIjVBvtBmrqX0WvkpZ3DYOYwGL3QDuIUtKarpEII=","cKn2pHge4p72bHZX6RcPkCSMotE3yKol468IJfCIBSs=","ns1MuHuvJ97vk/1G9RavyVW40bQqScr\u002BntDnZSwZUHA="],"CachedAssets":{},"CachedCopyCandidates":{}} \ No newline at end of file +{"GlobalPropertiesHash":"GuRprL5mC7hc0CG8FgEPpIWKx/Dfl1Jhxvhk8sWxBEQ=","FingerprintPatternsHash":"gq3WsqcKBUGTSNle7RKKyXRIwh7M8ccEqOqYvIzoM04=","PropertyOverridesHash":"8ZRc1sGeVrPBx4lD717BgRaQekyh78QKV9SKsdt638U=","InputHashes":["kIO\u002BgVQX72rEP/AM8N4erO8boVd0NQ5bkxTtUbSKS9I=","Uf8MX/\u002BVloY39fAvymRXdZ4qt/FRES4KRvClr57fYDU=","lfZuIjVBvtBmrqX0WvkpZ3DYOYwGL3QDuIUtKarpEII=","cKn2pHge4p72bHZX6RcPkCSMotE3yKol468IJfCIBSs=","YDM8gir9t/JobnY2IBraj9MVLPnhuLmU9uuLWanHPfo="],"CachedAssets":{},"CachedCopyCandidates":{}} \ No newline at end of file diff --git a/BookHive/obj/Debug/net10.0/rjsmrazor.dswa.cache.json b/BookHive/obj/Debug/net10.0/rjsmrazor.dswa.cache.json index aec49f1..78bae3d 100644 --- a/BookHive/obj/Debug/net10.0/rjsmrazor.dswa.cache.json +++ b/BookHive/obj/Debug/net10.0/rjsmrazor.dswa.cache.json @@ -1 +1 @@ -{"GlobalPropertiesHash":"03RR8FZ+u5Ay9wTZirfGS5vS3BFumeGaLKPk0IyeRqs=","FingerprintPatternsHash":"gq3WsqcKBUGTSNle7RKKyXRIwh7M8ccEqOqYvIzoM04=","PropertyOverridesHash":"8ZRc1sGeVrPBx4lD717BgRaQekyh78QKV9SKsdt638U=","InputHashes":["kIO\u002BgVQX72rEP/AM8N4erO8boVd0NQ5bkxTtUbSKS9I=","Uf8MX/\u002BVloY39fAvymRXdZ4qt/FRES4KRvClr57fYDU=","lfZuIjVBvtBmrqX0WvkpZ3DYOYwGL3QDuIUtKarpEII=","cKn2pHge4p72bHZX6RcPkCSMotE3yKol468IJfCIBSs=","ns1MuHuvJ97vk/1G9RavyVW40bQqScr\u002BntDnZSwZUHA="],"CachedAssets":{},"CachedCopyCandidates":{}} \ No newline at end of file +{"GlobalPropertiesHash":"03RR8FZ+u5Ay9wTZirfGS5vS3BFumeGaLKPk0IyeRqs=","FingerprintPatternsHash":"gq3WsqcKBUGTSNle7RKKyXRIwh7M8ccEqOqYvIzoM04=","PropertyOverridesHash":"8ZRc1sGeVrPBx4lD717BgRaQekyh78QKV9SKsdt638U=","InputHashes":["kIO\u002BgVQX72rEP/AM8N4erO8boVd0NQ5bkxTtUbSKS9I=","Uf8MX/\u002BVloY39fAvymRXdZ4qt/FRES4KRvClr57fYDU=","lfZuIjVBvtBmrqX0WvkpZ3DYOYwGL3QDuIUtKarpEII=","cKn2pHge4p72bHZX6RcPkCSMotE3yKol468IJfCIBSs=","YDM8gir9t/JobnY2IBraj9MVLPnhuLmU9uuLWanHPfo="],"CachedAssets":{},"CachedCopyCandidates":{}} \ No newline at end of file diff --git a/BookHive/obj/rider.project.restore.info b/BookHive/obj/rider.project.restore.info index a20b497..8a8d781 100644 --- a/BookHive/obj/rider.project.restore.info +++ b/BookHive/obj/rider.project.restore.info @@ -1 +1 @@ -17731267691332367 \ No newline at end of file +17731341506250102 \ No newline at end of file