diff --git a/API_SQLuedo/API/Controllers/InquiriesController.cs b/API_SQLuedo/API/Controllers/InquiriesController.cs index ae9c46a..5b8c864 100644 --- a/API_SQLuedo/API/Controllers/InquiriesController.cs +++ b/API_SQLuedo/API/Controllers/InquiriesController.cs @@ -37,7 +37,7 @@ namespace API.Controllers return Ok(inquiries); } - [HttpGet("inquiry/{id}")] + [HttpGet("inquiry/{id:int}")] [ProducesResponseType(typeof(InquiryDTO), 200)] [ProducesResponseType(typeof(string), 404)] public IActionResult GetInquiryById(int id) @@ -54,7 +54,7 @@ namespace API.Controllers } } - [HttpGet("inquiry/{title}")] + [HttpGet("inquiry/{title:alpha}")] [ProducesResponseType(typeof(InquiryDTO), 200)] [ProducesResponseType(typeof(string), 404)] public IActionResult GetInquiryByTitle(string title) diff --git a/API_SQLuedo/API/Controllers/LessonsController.cs b/API_SQLuedo/API/Controllers/LessonsController.cs index 2401a6c..eaaec1b 100644 --- a/API_SQLuedo/API/Controllers/LessonsController.cs +++ b/API_SQLuedo/API/Controllers/LessonsController.cs @@ -13,11 +13,11 @@ namespace API.Controllers [ApiController] public class LessonsController : Controller { - private ILessonDataService _lessonDataService; + private ILessonService _lessonDataService; private readonly ILogger _logger; - public LessonsController(ILessonDataService lessonDataService, ILogger logger) + public LessonsController(ILessonService lessonDataService, ILogger logger) { _lessonDataService = lessonDataService; _logger = logger; @@ -38,7 +38,7 @@ namespace API.Controllers return Ok(_lessonDataService.GetLessons(page, number, orderCriteria)); } - [HttpGet("lesson/{id}")] + [HttpGet("lesson/{id:int}")] [ProducesResponseType(typeof(LessonDTO), 200)] [ProducesResponseType(typeof(string), 404)] public IActionResult GetLessonById(int id) @@ -55,7 +55,7 @@ namespace API.Controllers } } - [HttpGet("lesson/{title}")] + [HttpGet("lesson/{title:alpha}")] [ProducesResponseType(typeof(LessonDTO), 200)] [ProducesResponseType(typeof(string), 404)] public IActionResult GetLessonByTitle(string title) diff --git a/API_SQLuedo/API/Controllers/ParagraphsController.cs b/API_SQLuedo/API/Controllers/ParagraphsController.cs index 8cde6f1..9196e21 100644 --- a/API_SQLuedo/API/Controllers/ParagraphsController.cs +++ b/API_SQLuedo/API/Controllers/ParagraphsController.cs @@ -13,11 +13,11 @@ namespace API.Controllers [ApiController] public class ParagraphsController : Controller { - private IParagraphDataService _paragraphDataService; + private IParagraphService _paragraphDataService; private readonly ILogger _logger; - public ParagraphsController(IParagraphDataService paragraphDataService, ILogger logger) + public ParagraphsController(IParagraphService paragraphDataService, ILogger logger) { _paragraphDataService = paragraphDataService; _logger = logger; @@ -38,7 +38,7 @@ namespace API.Controllers return Ok(_paragraphDataService.GetParagraphs(page, number, orderCriteria)); } - [HttpGet("paragraph/{id}")] + [HttpGet("paragraph/{id:int}")] [ProducesResponseType(typeof(ParagraphDTO), 200)] [ProducesResponseType(typeof(string), 404)] public IActionResult GetParagraphById(int id) @@ -54,7 +54,7 @@ namespace API.Controllers } } - [HttpGet("paragraph/{title}")] + [HttpGet("paragraph/{title:alpha}")] [ProducesResponseType(typeof(ParagraphDTO), 200)] [ProducesResponseType(typeof(string), 404)] public IActionResult GetParagraphByTitle(string title) diff --git a/API_SQLuedo/API/Controllers/SuccessesController.cs b/API_SQLuedo/API/Controllers/SuccessesController.cs index a335f0f..09df742 100644 --- a/API_SQLuedo/API/Controllers/SuccessesController.cs +++ b/API_SQLuedo/API/Controllers/SuccessesController.cs @@ -13,11 +13,11 @@ namespace API.Controllers [ApiController] public class SuccessesController : Controller { - private ISuccessDataService _successDataService; + private ISuccessService _successDataService; private readonly ILogger _logger; - public SuccessesController(ISuccessDataService successDataService, ILogger logger) + public SuccessesController(ISuccessService successDataService, ILogger logger) { _successDataService = successDataService; _logger = logger; @@ -38,7 +38,7 @@ namespace API.Controllers return Ok(_successDataService.GetSuccesses(page, number, orderCriteria)); } - [HttpGet("success/{id}")] + [HttpGet("success/user/{id:int}")] [ProducesResponseType(typeof(SuccessDTO), 200)] [ProducesResponseType(typeof(string), 404)] public IActionResult GetSuccessByUserId(int userId) @@ -54,7 +54,7 @@ namespace API.Controllers } } - [HttpGet("success/{inquiryId}")] + [HttpGet("success/inquiry/{inquiryId:int}")] [ProducesResponseType(typeof(SuccessDTO), 200)] [ProducesResponseType(typeof(string), 404)] public IActionResult GetSuccessByInquiryId(int inquiryId) diff --git a/API_SQLuedo/API/Controllers/UserController.cs b/API_SQLuedo/API/Controllers/UserController.cs index b90fd11..4982054 100644 --- a/API_SQLuedo/API/Controllers/UserController.cs +++ b/API_SQLuedo/API/Controllers/UserController.cs @@ -28,7 +28,6 @@ namespace API.Controllers logger.LogInformation("[INFORMATION] {nb} Utilisateur(s) trouvé(s)", users.Count); return Ok(users); } - [HttpGet("user/id/{id}")] [ProducesResponseType(typeof(UserDTO), 200)] [ProducesResponseType(typeof(string), 404)] @@ -45,8 +44,7 @@ namespace API.Controllers return NotFound(); } } - - [HttpGet("user/username/{username}")] + [HttpGet("user/{username:alpha}")] [ProducesResponseType(typeof(UserDTO), 200)] [ProducesResponseType(typeof(string), 404)] public async Task GetUserByUsername(string username) diff --git a/API_SQLuedo/StubbedContextLib/StubbedContext.cs b/API_SQLuedo/StubbedContextLib/StubbedContext.cs index 541bc48..58cc5b7 100644 --- a/API_SQLuedo/StubbedContextLib/StubbedContext.cs +++ b/API_SQLuedo/StubbedContextLib/StubbedContext.cs @@ -48,12 +48,7 @@ public class StubbedContext : UserDbContext prf: KeyDerivationPrf.HMACSHA256, iterationCount: 100000, numBytesRequested: 256 / 8)), "Victor.GABORIT@etu.uca.fr", true)); - - modelBuilder.Entity().HasData( - new InquiryEntity(1, "L'enquête de la carotte", "La description de l'inquiry1", true, 1, 1), - new InquiryEntity(2, "L'enquête sur les orang outan", "The new description", false, 2, 2), - new InquiryEntity(3, "L'enquête sur les parapluies", "Il pleuvait", false, 3, 3)); - + modelBuilder.Entity().HasData( new InquiryTableEntity(1, "Inquiry1", "Server=localhost;Database=Inquiry1;Trusted_Connection=True;MultipleActiveResultSets=true"), @@ -66,5 +61,10 @@ public class StubbedContext : UserDbContext new SolutionEntity(1, "Maxime", "Sapountzis", "La cuisine", "Le couteau", "Parce que c'est Maxime"), new SolutionEntity(2, "Johnny", "Ratton", "La cuisine", "Le couteau", "Parce que il est ra****"), new SolutionEntity(3, "Erwan", "Menager", "La salle de bain", "L'arachide", "Parce que c'est Erwan")); + + modelBuilder.Entity().HasData( + new InquiryEntity(1, "L'enquête de la carotte", "La description de l'inquiry1", true, 1, 1), + new InquiryEntity(2, "L'enquête sur les orang outan", "The new description", false, 2, 2), + new InquiryEntity(3, "L'enquête sur les parapluies", "Il pleuvait", false, 3, 3)); } } \ No newline at end of file diff --git a/API_SQLuedo/TestConsoleAPI/Program.cs b/API_SQLuedo/TestConsoleAPI/Program.cs index b4a0be4..d24aea0 100644 --- a/API_SQLuedo/TestConsoleAPI/Program.cs +++ b/API_SQLuedo/TestConsoleAPI/Program.cs @@ -26,7 +26,7 @@ ILogger successLogger = factory.CreateLogger(context, new Shared.UserDataService(context), new LessonDataService(context), new InquiryDataService(context), new ParagraphDataService(context), new SuccessDataService(context))); - var inquiryController = new InquiriesController(new InquiryDataService(context), inquiryLogger); + var inquiryController = new InquiriesController(new DataService(context, new Shared.UserDataService(context), new LessonDataService(context), new InquiryDataService(context), new ParagraphDataService(context), new SuccessDataService(context)), inquiryLogger); var paragraphController = new ParagraphsController(new ParagraphDataService(context), paragraphLogger); var lessonController = new LessonsController(new LessonDataService(context), lessonLogger); var successController = new SuccessesController(new SuccessDataService(context), successLogger); @@ -41,10 +41,10 @@ using (var context = new UserDbContext(options)) } } - void PrintInquiries() + async void PrintInquiries() { Console.WriteLine(); - var inquiries = inquiryController.GetInquiries(1, 10, InquiryOrderCriteria.None) as OkObjectResult; + var inquiries = await inquiryController.GetInquiries(1, 10, InquiryOrderCriteria.None) as OkObjectResult; foreach (var item in inquiries.Value as IEnumerable) { Console.WriteLine(item);