From f9f98e5705fc9f879860c7d7e535d7d290109e84 Mon Sep 17 00:00:00 2001 From: "Johnny.Ratton" Date: Sun, 31 Mar 2024 20:23:35 +0200 Subject: [PATCH] =?UTF-8?q?Ajout=20des=20controller=20notepad,=20solution?= =?UTF-8?q?=20et=20des=20services=20associ=C3=A9s=20+=20modification=20des?= =?UTF-8?q?=20controllers=20et=20services=20actuels=20pour=20se=20conforme?= =?UTF-8?q?r=20au=20site=20PHP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../API/Controllers/InquiryTableController.cs | 42 ++++++++ .../API/Controllers/LessonsController.cs | 10 ++ .../API/Controllers/NotepadController.cs | 97 +++++++++++++++++++ .../API/Controllers/ParagraphsController.cs | 16 +++ .../API/Controllers/SolutionController.cs | 43 ++++++++ API_SQLuedo/API/Program.cs | 9 ++ .../API/Service/InquiryTableDataServiceAPI.cs | 13 +++ .../API/Service/LessonDataServiceAPI.cs | 5 + .../API/Service/NotepadDataServiceAPI.cs | 24 +++++ .../API/Service/ParagraphDataServiceAPI.cs | 5 + .../API/Service/SolutionDataServiceAPI.cs | 14 +++ .../Service/InquiryTableDataService.cs | 27 ++++++ .../Service/LessonDataService.cs | 5 + .../Service/NotepadDataService.cs | 63 ++++++++++++ .../Service/ParagraphDataService.cs | 11 +++ .../Service/SolutionDataService.cs | 26 +++++ API_SQLuedo/Shared/IInquiryTableService.cs | 6 ++ API_SQLuedo/Shared/ILessonService.cs | 1 + API_SQLuedo/Shared/INotepadService.cs | 10 ++ API_SQLuedo/Shared/IParagraphService.cs | 1 + API_SQLuedo/Shared/ISolutionService.cs | 6 ++ .../StubbedContextLib/StubbedContext.cs | 24 +++++ 22 files changed, 458 insertions(+) create mode 100644 API_SQLuedo/API/Controllers/InquiryTableController.cs create mode 100644 API_SQLuedo/API/Controllers/NotepadController.cs create mode 100644 API_SQLuedo/API/Controllers/SolutionController.cs create mode 100644 API_SQLuedo/API/Service/InquiryTableDataServiceAPI.cs create mode 100644 API_SQLuedo/API/Service/NotepadDataServiceAPI.cs create mode 100644 API_SQLuedo/API/Service/SolutionDataServiceAPI.cs create mode 100644 API_SQLuedo/DbDataManager/Service/InquiryTableDataService.cs create mode 100644 API_SQLuedo/DbDataManager/Service/NotepadDataService.cs create mode 100644 API_SQLuedo/DbDataManager/Service/SolutionDataService.cs create mode 100644 API_SQLuedo/Shared/IInquiryTableService.cs create mode 100644 API_SQLuedo/Shared/INotepadService.cs create mode 100644 API_SQLuedo/Shared/ISolutionService.cs diff --git a/API_SQLuedo/API/Controllers/InquiryTableController.cs b/API_SQLuedo/API/Controllers/InquiryTableController.cs new file mode 100644 index 0000000..fa9d3f5 --- /dev/null +++ b/API_SQLuedo/API/Controllers/InquiryTableController.cs @@ -0,0 +1,42 @@ +using Asp.Versioning; +using Dto; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http.HttpResults; +using Microsoft.AspNetCore.Mvc; +using Shared; + +namespace API.Controllers; + +[Route("api/v{version:apiVersion}/[controller]")] +[Authorize] +[ApiVersion("1.0")] +[ApiController] +public class InquiryTableController : Controller +{ + private readonly IInquiryTableService _inquiryTableService; + + private readonly ILogger _logger; + + public InquiryTableController(IInquiryTableService inquiryTableService, ILogger logger) + { + _inquiryTableService = inquiryTableService; + _logger = logger; + } + + [HttpGet("database/{id:int}")] + [ProducesResponseType(typeof(string), 200)] + [ProducesResponseType(typeof(string), 404)] + public IActionResult GetSolutionByInquiryById(int id) + { + try + { + _logger.LogInformation("[INFORMATION] La base de données pour l'enquête avec l'id {id} a été trouvé.", id); + return Ok(new KeyValuePair("database", _inquiryTableService.GetDatabaseNameByInquiryId(id))); + } + catch (ArgumentException) + { + _logger.LogError("[ERREUR] Aucune base de données trouvée pour l'enquête avec l'id {id}.", id); + return NotFound(); + } + } +} \ No newline at end of file diff --git a/API_SQLuedo/API/Controllers/LessonsController.cs b/API_SQLuedo/API/Controllers/LessonsController.cs index c02cc6b..95b65ad 100644 --- a/API_SQLuedo/API/Controllers/LessonsController.cs +++ b/API_SQLuedo/API/Controllers/LessonsController.cs @@ -39,6 +39,16 @@ namespace API.Controllers _logger.LogInformation("[INFORMATION] {nb} Leçon(s) trouvée(s)", nbLesson); return Ok(_lessonDataService.GetLessons(page, number, orderCriteria)); } + + [HttpGet("lessons/number")] + [ProducesResponseType(typeof(KeyValuePair), 200)] + [ProducesResponseType(typeof(string), 204)] + public IActionResult GetNumberOfLessons() + { + var nbLesson = _lessonDataService.GetNumberOfLessons(); + _logger.LogInformation("[INFORMATION] {nb} Leçon(s) trouvée(s)", nbLesson); + return Ok(new KeyValuePair("nbLessons",nbLesson)); + } [HttpGet("lesson/{id:int}")] [ProducesResponseType(typeof(LessonDto), 200)] diff --git a/API_SQLuedo/API/Controllers/NotepadController.cs b/API_SQLuedo/API/Controllers/NotepadController.cs new file mode 100644 index 0000000..1eb3215 --- /dev/null +++ b/API_SQLuedo/API/Controllers/NotepadController.cs @@ -0,0 +1,97 @@ +using Asp.Versioning; +using Dto; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Shared; + +namespace API.Controllers; + +[Route("api/v{version:apiVersion}/[controller]")] +[Authorize] +[ApiVersion("1.0")] +[ApiController] +public class NotepadController : Controller +{ + private readonly INotepadService _notepadDataService; + + private readonly ILogger _logger; + + public NotepadController(INotepadService notepadService, ILogger logger) + { + _notepadDataService = notepadService; + _logger = logger; + } + + [HttpGet("notepad/{userId:int}/{inquiryId:int}")] + [ProducesResponseType(typeof(NotepadDto), 200)] + [ProducesResponseType(typeof(void), 404)] + public IActionResult GetNotepadByUserAndInquiryById(int userId, int inquiryId) + { + try + { + _logger.LogInformation( + "[INFORMATION] Le bloc-notes de l'utilisateur avec l'id {id} et l'enquête avec l'id {idInquiry} a été trouvé.", + userId, inquiryId); + return Ok(_notepadDataService.GetNotepadFromUserAndInquiryId(userId,inquiryId)); + } + catch (ArgumentException) + { + _logger.LogError( + "[ERREUR] Aucun bloc-notes trouvé pour l'utilisateur avec l'id {id} et l'enquête avec l'id {inquiryId}.", + userId, inquiryId); + return NotFound(); + } + } + + [HttpPost("notepad")] + [ProducesResponseType(typeof(void), 200)] + [ProducesResponseType(typeof(void), 404)] + public IActionResult SetNotepadByUserAndInquiryById([FromBody] NotepadDto notepad) + { + try + { + if (notepad.InquiryId == null || notepad.UserId == null || notepad.Notes == null) + { + return BadRequest(); + } + _notepadDataService.SetNotepadFromUserAndInquiryId(notepad.UserId, notepad.InquiryId, notepad.Notes); + _logger.LogInformation( + "[INFORMATION] Le bloc-notes de l'utilisateur avec l'id {id} et l'enquête avec l'id {idInquiry} a été créé.", + notepad.UserId, notepad.InquiryId); + return Ok(); + } + catch (ArgumentException) + { + _logger.LogError( + "[ERREUR] Aucun bloc-notes n'a pu être créé pour l'utilisateur avec l'id {id} et l'enquête avec l'id {inquiryId}.", + notepad.UserId, notepad.InquiryId); + return NotFound(); + } + } + + [HttpPut("notepad")] + [ProducesResponseType(typeof(void), 203)] + [ProducesResponseType(typeof(void), 404)] + public IActionResult UpdateNotepadByUserAndInquiryById([FromBody] NotepadDto notepad) + { + try + { + if (notepad.InquiryId == null || notepad.UserId == null || notepad.Notes == null) + { + return BadRequest(); + } + _notepadDataService.UpdateNotepadFromUserAndInquiryId(notepad.UserId, notepad.InquiryId, notepad.Notes); + _logger.LogInformation( + "[INFORMATION] Le bloc-notes de l'utilisateur avec l'id {id} et l'enquête avec l'id {idInquiry} a été mis à jour.", + notepad.UserId, notepad.InquiryId); + return Ok(); + } + catch (ArgumentException) + { + _logger.LogError( + "[ERREUR] Aucun bloc-notes n'a pu être mis à jour pour l'utilisateur avec l'id {id} et l'enquête avec l'id {inquiryId}.", + notepad.UserId, notepad.InquiryId); + return NotFound(); + } + } +} \ No newline at end of file diff --git a/API_SQLuedo/API/Controllers/ParagraphsController.cs b/API_SQLuedo/API/Controllers/ParagraphsController.cs index a8fa71a..1975928 100644 --- a/API_SQLuedo/API/Controllers/ParagraphsController.cs +++ b/API_SQLuedo/API/Controllers/ParagraphsController.cs @@ -39,6 +39,22 @@ namespace API.Controllers _logger.LogInformation("[INFORMATION] {nb} Paragraphe(s) trouvé(s)", nbParagraph); return Ok(_paragraphDataService.GetParagraphs(page, number, orderCriteria)); } + + [HttpGet("paragraphs/lesson/{id:int}")] + [ProducesResponseType(typeof(IEnumerable), 200)] + [ProducesResponseType(typeof(string), 204)] + public IActionResult GetParagraphsByLessonId(int id) + { + var nbParagraph = _paragraphDataService.GetParagraphsByLessonId(id).ToList().Count; + if (nbParagraph == 0) + { + _logger.LogError("[ERREUR] Aucun paragraphe trouvé."); + return StatusCode(204); + } + + _logger.LogInformation("[INFORMATION] {nb} Paragraphe(s) trouvé(s)", nbParagraph); + return Ok(_paragraphDataService.GetParagraphsByLessonId(id)); + } [HttpGet("paragraph/{id:int}")] [ProducesResponseType(typeof(ParagraphDto), 200)] diff --git a/API_SQLuedo/API/Controllers/SolutionController.cs b/API_SQLuedo/API/Controllers/SolutionController.cs new file mode 100644 index 0000000..f0ccf35 --- /dev/null +++ b/API_SQLuedo/API/Controllers/SolutionController.cs @@ -0,0 +1,43 @@ +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Dto; +using Model.OrderCriteria; +using Shared; +using Asp.Versioning; + +namespace API.Controllers +{ + [Route("api/v{version:apiVersion}/[controller]")] + [Authorize] + [ApiVersion("1.0")] + [ApiController] + public class SolutionController : Controller + { + private readonly ISolutionService _solutionDataService; + + private readonly ILogger _logger; + + public SolutionController(ISolutionService solutionDataService, ILogger logger) + { + _solutionDataService = solutionDataService; + _logger = logger; + } + + [HttpGet("solution/{id:int}")] + [ProducesResponseType(typeof(SolutionDto), 200)] + [ProducesResponseType(typeof(string), 404)] + public IActionResult GetSolutionByInquiryById(int id) + { + try + { + _logger.LogInformation("[INFORMATION] L'enquête avec l'id {id} a été trouvé.", id); + return Ok(_solutionDataService.GetSolutionByInquiryId(id)); + } + catch (ArgumentException) + { + _logger.LogError("[ERREUR] Aucune enquête trouvée avec l'id {id}.", id); + return NotFound(); + } + } + } +} \ No newline at end of file diff --git a/API_SQLuedo/API/Program.cs b/API_SQLuedo/API/Program.cs index e34c27e..650f0cc 100644 --- a/API_SQLuedo/API/Program.cs +++ b/API_SQLuedo/API/Program.cs @@ -28,6 +28,12 @@ builder.Services.AddScoped, BlackListDataService builder.Services.AddScoped, InquiryDataService>(); builder.Services.AddScoped, InquiryDataServiceApi>(); +builder.Services.AddScoped, SolutionDataService>(); +builder.Services.AddScoped, SolutionDataServiceAPI>(); + +builder.Services.AddScoped, InquiryTableDataService>(); +builder.Services.AddScoped, InquiryTableDataServiceAPI>(); + builder.Services.AddScoped, ParagraphDataService>(); builder.Services.AddScoped, ParagraphDataServiceApi>(); @@ -37,6 +43,9 @@ builder.Services.AddScoped, SuccessDataServiceApi>() builder.Services.AddScoped, LessonDataService>(); builder.Services.AddScoped, LessonDataServiceApi>(); +builder.Services.AddScoped, NotepadDataService>(); +builder.Services.AddScoped, NotepadDataServiceAPI>(); + builder.Services.AddDbContext(); builder.Services.AddDbContext(options => options.UseInMemoryDatabase("appDb")); builder.Services.AddIdentityApiEndpoints().AddEntityFrameworkStores(); diff --git a/API_SQLuedo/API/Service/InquiryTableDataServiceAPI.cs b/API_SQLuedo/API/Service/InquiryTableDataServiceAPI.cs new file mode 100644 index 0000000..71e11e5 --- /dev/null +++ b/API_SQLuedo/API/Service/InquiryTableDataServiceAPI.cs @@ -0,0 +1,13 @@ +using Dto; +using Entities; +using Shared; + +namespace API.Service; + +public class InquiryTableDataServiceAPI(IInquiryTableService inquiryTableService) : IInquiryTableService +{ + public string GetDatabaseNameByInquiryId(int id) + { + return inquiryTableService.GetDatabaseNameByInquiryId(id); + } +} \ No newline at end of file diff --git a/API_SQLuedo/API/Service/LessonDataServiceAPI.cs b/API_SQLuedo/API/Service/LessonDataServiceAPI.cs index 17fd31b..de6173e 100644 --- a/API_SQLuedo/API/Service/LessonDataServiceAPI.cs +++ b/API_SQLuedo/API/Service/LessonDataServiceAPI.cs @@ -14,6 +14,11 @@ public class LessonDataServiceApi(ILessonService lessonService) : return lessonsEntities.Select(e => e.FromEntityToDto()).ToList(); } + public int GetNumberOfLessons() + { + return lessonService.GetNumberOfLessons(); + } + public LessonDto GetLessonById(int id) => lessonService.GetLessonById(id).FromEntityToDto(); public LessonDto GetLessonByTitle(string title) => lessonService.GetLessonByTitle(title).FromEntityToDto(); diff --git a/API_SQLuedo/API/Service/NotepadDataServiceAPI.cs b/API_SQLuedo/API/Service/NotepadDataServiceAPI.cs new file mode 100644 index 0000000..263ee9e --- /dev/null +++ b/API_SQLuedo/API/Service/NotepadDataServiceAPI.cs @@ -0,0 +1,24 @@ +using Dto; +using Entities; +using Shared; +using Shared.Mapper; + +namespace API.Service; + +public class NotepadDataServiceAPI(INotepadService notepadService) : INotepadService +{ + public NotepadDto GetNotepadFromUserAndInquiryId(int userId, int inquiryId) + { + return notepadService.GetNotepadFromUserAndInquiryId(userId, inquiryId).FromEntityToDto(); + } + + public void SetNotepadFromUserAndInquiryId(int userId, int inquiryId, string notes) + { + notepadService.SetNotepadFromUserAndInquiryId(userId,inquiryId,notes); + } + + public void UpdateNotepadFromUserAndInquiryId(int userId, int inquiryId, string notes) + { + notepadService.UpdateNotepadFromUserAndInquiryId(userId,inquiryId,notes); + } +} \ No newline at end of file diff --git a/API_SQLuedo/API/Service/ParagraphDataServiceAPI.cs b/API_SQLuedo/API/Service/ParagraphDataServiceAPI.cs index 3b0cb16..39ceddf 100644 --- a/API_SQLuedo/API/Service/ParagraphDataServiceAPI.cs +++ b/API_SQLuedo/API/Service/ParagraphDataServiceAPI.cs @@ -15,6 +15,11 @@ public class ParagraphDataServiceApi(IParagraphService paragrap return paragraphsEntities.Select(e => e.FromEntityToDto()).ToList(); } + public IEnumerable GetParagraphsByLessonId(int lessonId) + { + return paragraphService.GetParagraphsByLessonId(lessonId).Select(p => p.FromEntityToDto()); + } + public ParagraphDto GetParagraphById(int id) => paragraphService.GetParagraphById(id).FromEntityToDto(); public ParagraphDto GetParagraphByTitle(string title) => diff --git a/API_SQLuedo/API/Service/SolutionDataServiceAPI.cs b/API_SQLuedo/API/Service/SolutionDataServiceAPI.cs new file mode 100644 index 0000000..f5d615d --- /dev/null +++ b/API_SQLuedo/API/Service/SolutionDataServiceAPI.cs @@ -0,0 +1,14 @@ +using Dto; +using Entities; +using Shared; +using Shared.Mapper; + +namespace API.Service; + +public class SolutionDataServiceAPI(ISolutionService solutionService) : ISolutionService +{ + public SolutionDto GetSolutionByInquiryId(int id) + { + return solutionService.GetSolutionByInquiryId(id).FromEntityToDto(); + } +} \ No newline at end of file diff --git a/API_SQLuedo/DbDataManager/Service/InquiryTableDataService.cs b/API_SQLuedo/DbDataManager/Service/InquiryTableDataService.cs new file mode 100644 index 0000000..9b968d9 --- /dev/null +++ b/API_SQLuedo/DbDataManager/Service/InquiryTableDataService.cs @@ -0,0 +1,27 @@ +using DbContextLib; +using Entities; +using Shared; + +namespace DbDataManager.Service; + +public class InquiryTableDataService : IInquiryTableService +{ + private UserDbContext DbContext { get; set; } + + public InquiryTableDataService(UserDbContext context) + { + DbContext = context; + context.Database.EnsureCreated(); + } + + public string GetDatabaseNameByInquiryId(int id) + { + var inquiryTable = DbContext.InquiryTables.FirstOrDefault(i => i.OwnerId == id); + if (inquiryTable == null) + { + throw new ArgumentException($"Erreur, impossible de trouver l'objet InquiryTable pour l'enquête d'id {id}", + nameof(id)); + } + return inquiryTable.DatabaseName; + } +} \ No newline at end of file diff --git a/API_SQLuedo/DbDataManager/Service/LessonDataService.cs b/API_SQLuedo/DbDataManager/Service/LessonDataService.cs index aa67a64..ffda92e 100644 --- a/API_SQLuedo/DbDataManager/Service/LessonDataService.cs +++ b/API_SQLuedo/DbDataManager/Service/LessonDataService.cs @@ -51,6 +51,11 @@ public class LessonDataService : ILessonService return lessons; } + public int GetNumberOfLessons() + { + return DbContext.Lessons.Count(); + } + public LessonEntity GetLessonById(int id) { var lessonEntity = DbContext.Lessons.FirstOrDefault(u => u.Id == id); diff --git a/API_SQLuedo/DbDataManager/Service/NotepadDataService.cs b/API_SQLuedo/DbDataManager/Service/NotepadDataService.cs new file mode 100644 index 0000000..b4f9cdc --- /dev/null +++ b/API_SQLuedo/DbDataManager/Service/NotepadDataService.cs @@ -0,0 +1,63 @@ +using DbContextLib; +using Entities; +using Shared; + +namespace DbDataManager.Service; + +public class NotepadDataService : INotepadService +{ + private UserDbContext DbContext { get; set; } + + public NotepadDataService(UserDbContext context) + { + DbContext = context; + context.Database.EnsureCreated(); + } + public NotepadEntity GetNotepadFromUserAndInquiryId(int userId, int inquiryId) + { + var user = DbContext.Users.FirstOrDefault(u => u.Id == userId); + if (user == null) + { + throw new ArgumentException("Erreur, aucun utilisateur ne possède l'ID fourni"); + } + var inquiry = DbContext.Inquiries.FirstOrDefault(i => i.Id == inquiryId); + if (inquiry == null) + { + throw new ArgumentException("Erreur, aucune enquête ne possède l'ID fourni"); + } + var notepad = DbContext.Notepads.FirstOrDefault(n => n.UserId == userId && n.InquiryId == inquiryId); + if (notepad == null) + { + throw new ArgumentException("Erreur, aucun bloc-notes n'existe pour l'utilisateur et l'enquête donnés"); + } + return notepad; + } + + public void SetNotepadFromUserAndInquiryId(int userId, int inquiryId, string notes) + { + var user = DbContext.Users.FirstOrDefault(u => u.Id == userId); + if (user == null) + { + throw new ArgumentException("Erreur, aucun utilisateur ne possède l'ID fourni"); + } + var inquiry = DbContext.Inquiries.FirstOrDefault(i => i.Id == inquiryId); + if (inquiry == null) + { + throw new ArgumentException("Erreur, aucune enquête ne possède l'ID fourni"); + } + var notepad = DbContext.Notepads.FirstOrDefault(n => n.UserId == userId && n.InquiryId == inquiryId); + if (notepad != null) + { + throw new ArgumentException("Erreur, un bloc-notes existe déjà pour l'utilisateur et l'enquête donnés"); + } + DbContext.Notepads.Add(new NotepadEntity { UserId = userId, InquiryId = inquiryId, Notes = notes }); + DbContext.SaveChangesAsync(); + } + + public void UpdateNotepadFromUserAndInquiryId(int userId, int inquiryId, string notes) + { + var notepad = GetNotepadFromUserAndInquiryId(userId, inquiryId); + notepad.Notes = notes; + DbContext.SaveChangesAsync(); + } +} \ No newline at end of file diff --git a/API_SQLuedo/DbDataManager/Service/ParagraphDataService.cs b/API_SQLuedo/DbDataManager/Service/ParagraphDataService.cs index 4c77183..1b38e05 100644 --- a/API_SQLuedo/DbDataManager/Service/ParagraphDataService.cs +++ b/API_SQLuedo/DbDataManager/Service/ParagraphDataService.cs @@ -54,6 +54,17 @@ public class ParagraphDataService : IParagraphService return paragraphs; } + public IEnumerable GetParagraphsByLessonId(int lessonId) + { + var lesson = DbContext.Lessons.FirstOrDefault(l => l.Id == lessonId); + if (lesson == null) + { + throw new ArgumentException($"Erreur, la leçon ayant pour id {lessonId} est introuvable."); + } + var list = DbContext.Paragraphs.Where(p => p.LessonId == lessonId); + return list; + } + public ParagraphEntity GetParagraphById(int id) { var paragraphEntity = DbContext.Paragraphs.FirstOrDefault(u => u.Id == id); diff --git a/API_SQLuedo/DbDataManager/Service/SolutionDataService.cs b/API_SQLuedo/DbDataManager/Service/SolutionDataService.cs new file mode 100644 index 0000000..d63992b --- /dev/null +++ b/API_SQLuedo/DbDataManager/Service/SolutionDataService.cs @@ -0,0 +1,26 @@ +using DbContextLib; +using Entities; +using Shared; + +namespace DbDataManager.Service; + +public class SolutionDataService : ISolutionService +{ + private UserDbContext DbContext { get; set; } + + public SolutionDataService(UserDbContext context) + { + DbContext = context; + context.Database.EnsureCreated(); + } + + public SolutionEntity GetSolutionByInquiryId(int id) + { + var solution = DbContext.Solutions.FirstOrDefault(s => s.OwnerId == id); + if (solution == null) + { + throw new ArgumentException($"Impossible de trouver la solution pour l'enquête d'id {id}", nameof(id)); + } + return solution; + } +} \ No newline at end of file diff --git a/API_SQLuedo/Shared/IInquiryTableService.cs b/API_SQLuedo/Shared/IInquiryTableService.cs new file mode 100644 index 0000000..fa3d5ff --- /dev/null +++ b/API_SQLuedo/Shared/IInquiryTableService.cs @@ -0,0 +1,6 @@ +namespace Shared; + +public interface IInquiryTableService +{ + public string GetDatabaseNameByInquiryId(int id); +} \ No newline at end of file diff --git a/API_SQLuedo/Shared/ILessonService.cs b/API_SQLuedo/Shared/ILessonService.cs index 51836e0..ab173fc 100644 --- a/API_SQLuedo/Shared/ILessonService.cs +++ b/API_SQLuedo/Shared/ILessonService.cs @@ -5,6 +5,7 @@ namespace Shared; public interface ILessonService { public IEnumerable GetLessons(int page, int number, LessonOrderCriteria orderCriteria); + public int GetNumberOfLessons(); public TLesson GetLessonById(int id); public TLesson GetLessonByTitle(string title); public bool DeleteLesson(int id); diff --git a/API_SQLuedo/Shared/INotepadService.cs b/API_SQLuedo/Shared/INotepadService.cs new file mode 100644 index 0000000..9e5bb6d --- /dev/null +++ b/API_SQLuedo/Shared/INotepadService.cs @@ -0,0 +1,10 @@ +namespace Shared; + +public interface INotepadService +{ + public TNotepad GetNotepadFromUserAndInquiryId(int userId, int inquiryId); + + public void SetNotepadFromUserAndInquiryId(int userId, int inquiryId, string notes); + + public void UpdateNotepadFromUserAndInquiryId(int userId, int inquiryId, string notes); +} \ No newline at end of file diff --git a/API_SQLuedo/Shared/IParagraphService.cs b/API_SQLuedo/Shared/IParagraphService.cs index 34a249b..7fc124e 100644 --- a/API_SQLuedo/Shared/IParagraphService.cs +++ b/API_SQLuedo/Shared/IParagraphService.cs @@ -5,6 +5,7 @@ namespace Shared public interface IParagraphService { public IEnumerable GetParagraphs(int page, int number, ParagraphOrderCriteria orderCriteria); + public IEnumerable GetParagraphsByLessonId(int lessonId); public TParagraph GetParagraphById(int id); public TParagraph GetParagraphByTitle(string title); public bool DeleteParagraph(int id); diff --git a/API_SQLuedo/Shared/ISolutionService.cs b/API_SQLuedo/Shared/ISolutionService.cs new file mode 100644 index 0000000..270ee5c --- /dev/null +++ b/API_SQLuedo/Shared/ISolutionService.cs @@ -0,0 +1,6 @@ +namespace Shared; + +public interface ISolutionService +{ + public TSolution GetSolutionByInquiryId(int id); +} \ No newline at end of file diff --git a/API_SQLuedo/StubbedContextLib/StubbedContext.cs b/API_SQLuedo/StubbedContextLib/StubbedContext.cs index b015ebc..1337b91 100644 --- a/API_SQLuedo/StubbedContextLib/StubbedContext.cs +++ b/API_SQLuedo/StubbedContextLib/StubbedContext.cs @@ -184,5 +184,29 @@ public class StubbedContext : UserDbContext IsFinished = true } ); + builder.Entity().HasData( + new LessonEntity + { + Id = 1, Title = "Lesson N°1", LastEdit = DateOnly.FromDateTime(DateTime.Now), LastPublisher = "Clément" + }, + new LessonEntity + { + Id = 2, Title = "Lesson N°2", LastEdit = DateOnly.FromDateTime(DateTime.Now), LastPublisher = "Clément" + }, + new LessonEntity + { + Id = 3, Title = "Lesson N°3", LastEdit = DateOnly.FromDateTime(DateTime.Now), LastPublisher = "Clément" + }, + new LessonEntity + { + Id = 4, Title = "Lesson N°4", LastEdit = DateOnly.FromDateTime(DateTime.Now), LastPublisher = "Clément" + } + ); + builder.Entity().HasData( + new ParagraphEntity { Id = 1, LessonId = 1, ContentTitle = "Paragraph N°1", ContentContent = "Content of paragraph N°1", Title = "Title Paragraph N°1", Content = "Content of paragraph N°1", Info = "Infos", Query = "SELECT * FROM Table", Comment = "Comment of paragraph N°1"}, + new ParagraphEntity { Id = 2, LessonId = 1, ContentTitle = "Paragraph N°2", ContentContent = "Content of paragraph N°2", Title = "Title Paragraph N°2", Content = "Content of paragraph N°2", Info = "Infos", Query = "SELECT * FROM Table", Comment = "Comment of paragraph N°2"}, + new ParagraphEntity { Id = 3, LessonId = 1, ContentTitle = "Paragraph N°3", ContentContent = "Content of paragraph N°3", Title = "Title Paragraph N°3", Content = "Content of paragraph N°3", Info = "Infos", Query = "SELECT * FROM Table", Comment = "Comment of paragraph N°3"}, + new ParagraphEntity { Id = 4, LessonId = 2, ContentTitle = "Paragraph N°1", ContentContent = "Content of paragraph N°1", Title = "Title Paragraph N°1", Content = "Content of paragraph N°1", Info = "Infos", Query = "SELECT * FROM Table", Comment = "Comment of paragraph N°1"} + ); } } \ No newline at end of file