merge depuis master
continuous-integration/drone/push Build is passing Details

MethodeExtensions
Victor GABORIT 1 year ago
commit 7192ebc3da

@ -37,7 +37,7 @@ namespace API.Controllers
return Ok(inquiries); return Ok(inquiries);
} }
[HttpGet("inquiry/{id}")] [HttpGet("inquiry/{id:int}")]
[ProducesResponseType(typeof(InquiryDTO), 200)] [ProducesResponseType(typeof(InquiryDTO), 200)]
[ProducesResponseType(typeof(string), 404)] [ProducesResponseType(typeof(string), 404)]
public IActionResult GetInquiryById(int id) 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(InquiryDTO), 200)]
[ProducesResponseType(typeof(string), 404)] [ProducesResponseType(typeof(string), 404)]
public IActionResult GetInquiryByTitle(string title) public IActionResult GetInquiryByTitle(string title)

@ -13,11 +13,11 @@ namespace API.Controllers
[ApiController] [ApiController]
public class LessonsController : Controller public class LessonsController : Controller
{ {
private ILessonDataService _lessonDataService; private ILessonService<LessonDTO> _lessonDataService;
private readonly ILogger<LessonsController> _logger; private readonly ILogger<LessonsController> _logger;
public LessonsController(ILessonDataService lessonDataService, ILogger<LessonsController> logger) public LessonsController(ILessonService<LessonDTO> lessonDataService, ILogger<LessonsController> logger)
{ {
_lessonDataService = lessonDataService; _lessonDataService = lessonDataService;
_logger = logger; _logger = logger;
@ -38,7 +38,7 @@ namespace API.Controllers
return Ok(_lessonDataService.GetLessons(page, number, orderCriteria)); return Ok(_lessonDataService.GetLessons(page, number, orderCriteria));
} }
[HttpGet("lesson/{id}")] [HttpGet("lesson/{id:int}")]
[ProducesResponseType(typeof(LessonDTO), 200)] [ProducesResponseType(typeof(LessonDTO), 200)]
[ProducesResponseType(typeof(string), 404)] [ProducesResponseType(typeof(string), 404)]
public IActionResult GetLessonById(int id) 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(LessonDTO), 200)]
[ProducesResponseType(typeof(string), 404)] [ProducesResponseType(typeof(string), 404)]
public IActionResult GetLessonByTitle(string title) public IActionResult GetLessonByTitle(string title)

@ -13,11 +13,11 @@ namespace API.Controllers
[ApiController] [ApiController]
public class ParagraphsController : Controller public class ParagraphsController : Controller
{ {
private IParagraphDataService _paragraphDataService; private IParagraphService<ParagraphDTO> _paragraphDataService;
private readonly ILogger<ParagraphsController> _logger; private readonly ILogger<ParagraphsController> _logger;
public ParagraphsController(IParagraphDataService paragraphDataService, ILogger<ParagraphsController> logger) public ParagraphsController(IParagraphService<ParagraphDTO> paragraphDataService, ILogger<ParagraphsController> logger)
{ {
_paragraphDataService = paragraphDataService; _paragraphDataService = paragraphDataService;
_logger = logger; _logger = logger;
@ -38,7 +38,7 @@ namespace API.Controllers
return Ok(_paragraphDataService.GetParagraphs(page, number, orderCriteria)); return Ok(_paragraphDataService.GetParagraphs(page, number, orderCriteria));
} }
[HttpGet("paragraph/{id}")] [HttpGet("paragraph/{id:int}")]
[ProducesResponseType(typeof(ParagraphDTO), 200)] [ProducesResponseType(typeof(ParagraphDTO), 200)]
[ProducesResponseType(typeof(string), 404)] [ProducesResponseType(typeof(string), 404)]
public IActionResult GetParagraphById(int id) 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(ParagraphDTO), 200)]
[ProducesResponseType(typeof(string), 404)] [ProducesResponseType(typeof(string), 404)]
public IActionResult GetParagraphByTitle(string title) public IActionResult GetParagraphByTitle(string title)

@ -13,11 +13,11 @@ namespace API.Controllers
[ApiController] [ApiController]
public class SuccessesController : Controller public class SuccessesController : Controller
{ {
private ISuccessDataService _successDataService; private ISuccessService<SuccessDTO> _successDataService;
private readonly ILogger<SuccessesController> _logger; private readonly ILogger<SuccessesController> _logger;
public SuccessesController(ISuccessDataService successDataService, ILogger<SuccessesController> logger) public SuccessesController(ISuccessService<SuccessDTO> successDataService, ILogger<SuccessesController> logger)
{ {
_successDataService = successDataService; _successDataService = successDataService;
_logger = logger; _logger = logger;
@ -38,7 +38,7 @@ namespace API.Controllers
return Ok(_successDataService.GetSuccesses(page, number, orderCriteria)); return Ok(_successDataService.GetSuccesses(page, number, orderCriteria));
} }
[HttpGet("success/{id}")] [HttpGet("success/user/{id:int}")]
[ProducesResponseType(typeof(SuccessDTO), 200)] [ProducesResponseType(typeof(SuccessDTO), 200)]
[ProducesResponseType(typeof(string), 404)] [ProducesResponseType(typeof(string), 404)]
public IActionResult GetSuccessByUserId(int userId) 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(SuccessDTO), 200)]
[ProducesResponseType(typeof(string), 404)] [ProducesResponseType(typeof(string), 404)]
public IActionResult GetSuccessByInquiryId(int inquiryId) public IActionResult GetSuccessByInquiryId(int inquiryId)

@ -28,7 +28,6 @@ namespace API.Controllers
logger.LogInformation("[INFORMATION] {nb} Utilisateur(s) trouvé(s)", users.Count); logger.LogInformation("[INFORMATION] {nb} Utilisateur(s) trouvé(s)", users.Count);
return Ok(users); return Ok(users);
} }
[HttpGet("user/id/{id}")] [HttpGet("user/id/{id}")]
[ProducesResponseType(typeof(UserDTO), 200)] [ProducesResponseType(typeof(UserDTO), 200)]
[ProducesResponseType(typeof(string), 404)] [ProducesResponseType(typeof(string), 404)]
@ -45,8 +44,7 @@ namespace API.Controllers
return NotFound(); return NotFound();
} }
} }
[HttpGet("user/{username:alpha}")]
[HttpGet("user/username/{username}")]
[ProducesResponseType(typeof(UserDTO), 200)] [ProducesResponseType(typeof(UserDTO), 200)]
[ProducesResponseType(typeof(string), 404)] [ProducesResponseType(typeof(string), 404)]
public async Task<IActionResult> GetUserByUsername(string username) public async Task<IActionResult> GetUserByUsername(string username)

@ -49,11 +49,6 @@ public class StubbedContext : UserDbContext
iterationCount: 100000, iterationCount: 100000,
numBytesRequested: 256 / 8)), "Victor.GABORIT@etu.uca.fr", true)); numBytesRequested: 256 / 8)), "Victor.GABORIT@etu.uca.fr", true));
modelBuilder.Entity<InquiryEntity>().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<InquiryTableEntity>().HasData( modelBuilder.Entity<InquiryTableEntity>().HasData(
new InquiryTableEntity(1, "Inquiry1", new InquiryTableEntity(1, "Inquiry1",
"Server=localhost;Database=Inquiry1;Trusted_Connection=True;MultipleActiveResultSets=true"), "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(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(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")); new SolutionEntity(3, "Erwan", "Menager", "La salle de bain", "L'arachide", "Parce que c'est Erwan"));
modelBuilder.Entity<InquiryEntity>().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));
} }
} }

@ -26,7 +26,7 @@ ILogger<SuccessesController> successLogger = factory.CreateLogger<SuccessesContr
using (var context = new UserDbContext(options)) using (var context = new UserDbContext(options))
{ {
var userController = new UsersController(userLogger, new DataService<UserDTO, LessonDTO, InquiryDTO, ParagraphDTO, SuccessDTO>(context, new Shared.UserDataService(context), new LessonDataService(context), new InquiryDataService(context), new ParagraphDataService(context), new SuccessDataService(context))); var userController = new UsersController(userLogger, new DataService<UserDTO, LessonDTO, InquiryDTO, ParagraphDTO, SuccessDTO>(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<UserDTO, LessonDTO, InquiryDTO, ParagraphDTO, SuccessDTO>(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 paragraphController = new ParagraphsController(new ParagraphDataService(context), paragraphLogger);
var lessonController = new LessonsController(new LessonDataService(context), lessonLogger); var lessonController = new LessonsController(new LessonDataService(context), lessonLogger);
var successController = new SuccessesController(new SuccessDataService(context), successLogger); 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(); 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<InquiryDTO>) foreach (var item in inquiries.Value as IEnumerable<InquiryDTO>)
{ {
Console.WriteLine(item); Console.WriteLine(item);

Loading…
Cancel
Save