diff --git a/API_SQLuedo/API/Controllers/InquiriesController.cs b/API_SQLuedo/API/Controllers/InquiriesController.cs index 5b8c864..26d6d80 100644 --- a/API_SQLuedo/API/Controllers/InquiriesController.cs +++ b/API_SQLuedo/API/Controllers/InquiriesController.cs @@ -95,12 +95,12 @@ namespace API.Controllers [ProducesResponseType(typeof(string), 400)] public IActionResult CreateInquiry([FromBody] InquiryDTO dto) { - if (dto.Title == null || dto.Description == null || dto.Database == null || dto.InquiryTable == null) + if (dto.Title == null || dto.Description == null) { return BadRequest(); } - _logger.LogInformation("[INFORMATION] Une enquête a été créé : title - {title}, description - {description}, isUser - {isUser}, database - {database}, inquiryTable - {inquiryTable}", dto.Title, dto.Description, dto.IsUser, dto.Database, dto.InquiryTable); - return Created(nameof(GetInquiries), _dataService.inquiryService.CreateInquiry(dto.Title, dto.Description, dto.IsUser, dto.Database, dto.InquiryTable)); + _logger.LogInformation("[INFORMATION] Une enquête a été créé : title - {title}, description - {description}, isUser - {isUser}", dto.Title, dto.Description, dto.IsUser); + return Created(nameof(GetInquiries), _dataService.inquiryService.CreateInquiry(dto.Title, dto.Description, dto.IsUser)); } [HttpPut("inquiry/{id}")] diff --git a/API_SQLuedo/API/Service/InquiryDataServiceAPI.cs b/API_SQLuedo/API/Service/InquiryDataServiceAPI.cs index 1143162..a276695 100644 --- a/API_SQLuedo/API/Service/InquiryDataServiceAPI.cs +++ b/API_SQLuedo/API/Service/InquiryDataServiceAPI.cs @@ -10,10 +10,9 @@ public class InquiryDataServiceApi(IInquiryService inquiryService { return inquiryService.AddItem(item); } - - public InquiryEntity CreateInquiry(string title, string description, bool isUser, int tableId, int solutionId) + public InquiryEntity CreateInquiry(string title, string description, bool isUser) { - return inquiryService.CreateInquiry(title, description, isUser, tableId, solutionId); + return inquiryService.CreateInquiry(title, description, isUser); } public bool DeleteInquiry(int id) diff --git a/API_SQLuedo/DbDataManager/Service/InquiryDataService.cs b/API_SQLuedo/DbDataManager/Service/InquiryDataService.cs index 06841a3..acbf0fe 100644 --- a/API_SQLuedo/DbDataManager/Service/InquiryDataService.cs +++ b/API_SQLuedo/DbDataManager/Service/InquiryDataService.cs @@ -69,23 +69,19 @@ public class InquiryDataService : IInquiryService updatingInquiry.Title = inquiry.Title; updatingInquiry.Description = inquiry.Description; updatingInquiry.IsUser = inquiry.IsUser; - updatingInquiry.IdInquiryTable = inquiry.IdInquiryTable; - updatingInquiry.IdDatabase = inquiry.IdDatabase; // Permet d'indiquer en Db que l'entité a été modifiée. DbContext.Entry(updatingInquiry).State = EntityState.Modified; DbContext.SaveChangesAsync(); return updatingInquiry; } - public InquiryEntity CreateInquiry(string title, string description, bool isUser, int tableId, int solutionId) + public InquiryEntity CreateInquiry(string title, string description, bool isUser) { var newInquiryEntity = new InquiryEntity() { Title = title, Description = description, - IsUser = isUser, - IdDatabase = tableId, - IdInquiryTable = solutionId, + IsUser = isUser }; DbContext.Inquiries.Add(newInquiryEntity); DbContext.SaveChangesAsync(); diff --git a/API_SQLuedo/Dto/InquiryDTO.cs b/API_SQLuedo/Dto/InquiryDTO.cs index 258aaab..5a436ed 100644 --- a/API_SQLuedo/Dto/InquiryDTO.cs +++ b/API_SQLuedo/Dto/InquiryDTO.cs @@ -10,25 +10,18 @@ public class InquiryDTO public bool IsUser { get; set; } - public int Database { get; set; } - public int InquiryTable { get; set; } - - public InquiryDTO(int id, string title, string description, bool isUser, int database, int inquiryTable) + public InquiryDTO(int id, string title, string description, bool isUser) { Id = id; Title = title; Description = description; IsUser = isUser; - Database = database; - InquiryTable = inquiryTable; } - public InquiryDTO(string title, string description, bool isUser, int database, int inquiryTable) + public InquiryDTO(string title, string description, bool isUser) { Title = title; Description = description; IsUser = isUser; - Database = database; - InquiryTable = inquiryTable; } } \ No newline at end of file diff --git a/API_SQLuedo/EntityFramework/InquiryEntity.cs b/API_SQLuedo/EntityFramework/InquiryEntity.cs index 3c43ee4..1647f0f 100644 --- a/API_SQLuedo/EntityFramework/InquiryEntity.cs +++ b/API_SQLuedo/EntityFramework/InquiryEntity.cs @@ -1,15 +1,15 @@ -namespace Entities; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Entities; public class InquiryEntity { + [Key] public int Id { get; } public string Title { get; set; } public string Description { get; set; } public bool IsUser { get; set; } - public int IdDatabase { get; set; } - public InquiryTableEntity Database { get; set; } - public int IdInquiryTable { get; set; } - public SolutionEntity InquiryTable { get; set; } public InquiryEntity() { @@ -20,36 +20,19 @@ public class InquiryEntity Id = id; } - public InquiryEntity(int id, string title, string description, bool isUser, InquiryTableEntity database, - SolutionEntity inquiryTable) - { - Id = id; - Title = title; - Description = description; - IsUser = isUser; - Database = database; - InquiryTable = inquiryTable; - } - - public InquiryEntity(string title, string description, bool isUser, InquiryTableEntity database, - SolutionEntity inquiryTable) + public InquiryEntity(string title, string description, bool isUser) { Id = 0; Title = title; Description = description; IsUser = isUser; - Database = database; - InquiryTable = inquiryTable; } - public InquiryEntity(int id, string title, string description, bool isUser, int database, - int inquiryTable) + public InquiryEntity(int id, string title, string description, bool isUser) { Id = id; Title = title; Description = description; IsUser = isUser; - IdDatabase = database; - IdInquiryTable = inquiryTable; } } \ No newline at end of file diff --git a/API_SQLuedo/Model/Inquiry.cs b/API_SQLuedo/Model/Inquiry.cs index 8aab55a..d2a805f 100644 --- a/API_SQLuedo/Model/Inquiry.cs +++ b/API_SQLuedo/Model/Inquiry.cs @@ -6,18 +6,14 @@ public class Inquiry public string Title { get; set; } public string Description { get; set; } public bool IsUser { get; set; } - public int Database { get; set; } - public int InquiryTable { get; set; } public Inquiry() { } - public Inquiry(int id, string title, string description, bool isUser, int database, int inquiryTable) + public Inquiry(int id, string title, string description, bool isUser) { Id = id; Title = title; Description = description; IsUser = isUser; - Database = database; - InquiryTable = inquiryTable; } } \ No newline at end of file diff --git a/API_SQLuedo/Shared/IInquiryDataService.cs b/API_SQLuedo/Shared/IInquiryDataService.cs index 682e4c6..79085f6 100644 --- a/API_SQLuedo/Shared/IInquiryDataService.cs +++ b/API_SQLuedo/Shared/IInquiryDataService.cs @@ -10,5 +10,5 @@ public interface IInquiryDataService : IInquiryService public InquiryDTO GetInquiryByTitle(string title); public bool DeleteInquiry(int id); public InquiryDTO UpdateInquiry(int id, InquiryDTO inquiry); - public InquiryDTO CreateInquiry(string title, string description, bool isUser, int tableId, int solutionId); + public InquiryDTO CreateInquiry(string title, string description, bool isUser); } \ No newline at end of file diff --git a/API_SQLuedo/Shared/IInquiryService.cs b/API_SQLuedo/Shared/IInquiryService.cs index 86cdfd9..10badfd 100644 --- a/API_SQLuedo/Shared/IInquiryService.cs +++ b/API_SQLuedo/Shared/IInquiryService.cs @@ -7,7 +7,7 @@ public interface IInquiryService : IGenericDataService where public IEnumerable GetInquiries(int page, int number, InquiryOrderCriteria orderCriteria); public TInquiry GetInquiryById(int id); public TInquiry GetInquiryByTitle(string title); - public bool DeleteInquiry(int id); - public TInquiry UpdateInquiry(int id, TInquiry inquiry); - public TInquiry CreateInquiry(string title, string description, bool isUser, int tableId, int solutionId); + public bool DeleteInquiry(int id); + public TInquiry UpdateInquiry(int id, TInquiry inquiry); + public TInquiry CreateInquiry(string title, string description, bool isUser); } \ No newline at end of file diff --git a/API_SQLuedo/Shared/InquiryDataService.cs b/API_SQLuedo/Shared/InquiryDataService.cs index 7a99076..8b9d092 100644 --- a/API_SQLuedo/Shared/InquiryDataService.cs +++ b/API_SQLuedo/Shared/InquiryDataService.cs @@ -61,9 +61,9 @@ public class InquiryDataService : IInquiryDataService return inquiryEntity.FromEntityToDTO(); } - public InquiryDTO CreateInquiry(string title, string description, bool isUser, int tableId, int solutionId) + public InquiryDTO CreateInquiry(string title, string description, bool isUser) { - var newInquiryEntity = new InquiryDTO(title, description, isUser, tableId, solutionId); + var newInquiryEntity = new InquiryDTO(title, description, isUser); DbContext.Inquiries.Add(newInquiryEntity.FromDTOToEntity()); DbContext.SaveChangesAsync(); return newInquiryEntity; @@ -91,8 +91,6 @@ public class InquiryDataService : IInquiryDataService updatingInquiry.Title = inquiry.Title; updatingInquiry.Description = inquiry.Description; updatingInquiry.IsUser = inquiry.IsUser; - updatingInquiry.IdDatabase = inquiry.Database; - updatingInquiry.IdInquiryTable = inquiry.InquiryTable; DbContext.SaveChangesAsync(); return updatingInquiry.FromEntityToDTO(); } diff --git a/API_SQLuedo/Shared/Mapper/InquiryMapper.cs b/API_SQLuedo/Shared/Mapper/InquiryMapper.cs index ace6105..cd18bc9 100644 --- a/API_SQLuedo/Shared/Mapper/InquiryMapper.cs +++ b/API_SQLuedo/Shared/Mapper/InquiryMapper.cs @@ -8,37 +8,32 @@ public static class InquiryMapper { public static Inquiry FromDTOToModel(this InquiryDTO InqDto) { - return new Inquiry(InqDto.Id, InqDto.Title, InqDto.Description, InqDto.IsUser, InqDto.Database, - InqDto.InquiryTable); + return new Inquiry(InqDto.Id, InqDto.Title, InqDto.Description, InqDto.IsUser); } public static Inquiry FromEntityToModel(this InquiryEntity InqEntity) { - return new Inquiry(InqEntity.Id, InqEntity.Title, InqEntity.Description, InqEntity.IsUser, - InqEntity.Database.OwnerId, InqEntity.InquiryTable.OwnerId); + return new Inquiry(InqEntity.Id, InqEntity.Title, InqEntity.Description, InqEntity.IsUser); } public static InquiryEntity FromModelToEntity(this Inquiry Inq) { - return new InquiryEntity(Inq.Id, Inq.Title, Inq.Description, Inq.IsUser, new InquiryTableEntity(Inq.Database), - new SolutionEntity(Inq.InquiryTable)); + return new InquiryEntity(Inq.Id, Inq.Title, Inq.Description, Inq.IsUser); } public static InquiryEntity FromDTOToEntity(this InquiryDTO InqDto) { - return new InquiryEntity(InqDto.Id, InqDto.Title, InqDto.Description, InqDto.IsUser, - new InquiryTableEntity(InqDto.Database), new SolutionEntity(InqDto.InquiryTable)); + return new InquiryEntity(InqDto.Id, InqDto.Title, InqDto.Description, InqDto.IsUser); } public static InquiryDTO FromModelToDTO(this Inquiry Inq) { - return new InquiryDTO(Inq.Id, Inq.Title, Inq.Description, Inq.IsUser, Inq.Database, Inq.InquiryTable); + return new InquiryDTO(Inq.Id, Inq.Title, Inq.Description, Inq.IsUser); } public static InquiryDTO FromEntityToDTO(this InquiryEntity InqEntity) { - return new InquiryDTO(InqEntity.Id, InqEntity.Title, InqEntity.Description, InqEntity.IsUser, - InqEntity.Database.OwnerId, InqEntity.InquiryTable.OwnerId); + return new InquiryDTO(InqEntity.Id, InqEntity.Title, InqEntity.Description, InqEntity.IsUser); } } \ No newline at end of file diff --git a/API_SQLuedo/StubbedContextLib/StubbedContext.cs b/API_SQLuedo/StubbedContextLib/StubbedContext.cs index 58cc5b7..9df19aa 100644 --- a/API_SQLuedo/StubbedContextLib/StubbedContext.cs +++ b/API_SQLuedo/StubbedContextLib/StubbedContext.cs @@ -63,8 +63,8 @@ public class StubbedContext : UserDbContext 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)); + new InquiryEntity(1, "L'enquête de la carotte", "La description de l'inquiry1", true), + new InquiryEntity(2, "L'enquête sur les orang outan", "The new description", false), + new InquiryEntity(3, "L'enquête sur les parapluies", "Il pleuvait", false)); } } \ No newline at end of file diff --git a/API_SQLuedo/TestConsoleAPI/Program.cs b/API_SQLuedo/TestConsoleAPI/Program.cs index d24aea0..d30a5d3 100644 --- a/API_SQLuedo/TestConsoleAPI/Program.cs +++ b/API_SQLuedo/TestConsoleAPI/Program.cs @@ -49,8 +49,8 @@ using (var context = new UserDbContext(options)) { Console.WriteLine(item); } - } - + } + void PrintParagraphs() { Console.WriteLine(); @@ -59,8 +59,8 @@ using (var context = new UserDbContext(options)) { Console.WriteLine(item); } - } - + } + void PrintLessons() { Console.WriteLine(); @@ -69,8 +69,8 @@ using (var context = new UserDbContext(options)) { Console.WriteLine(item); } - } - + } + void PrintSuccesses() { Console.WriteLine(); @@ -107,8 +107,8 @@ using (var context = new UserDbContext(options)) return; } Console.WriteLine(inquiry.Value as InquiryDTO); - } - + } + void SearchParagraphByTitle() { Console.WriteLine("\nVeuillez saisir le titre du paragraphe recherché : "); @@ -121,8 +121,8 @@ using (var context = new UserDbContext(options)) } Console.WriteLine(paragraph.Value as ParagraphDTO); - } - + } + void SearchLessonByTitle() { Console.WriteLine("\nVeuillez saisir le titre de la leçon recherchée : "); @@ -135,8 +135,8 @@ using (var context = new UserDbContext(options)) } Console.WriteLine(lesson.Value as LessonDTO); - } - + } + void SearchSuccessByUserId() { Console.WriteLine("\nVeuillez saisir l'identifiant de l'utilisateur du succès recherché : "); @@ -176,8 +176,8 @@ using (var context = new UserDbContext(options)) return; } Console.WriteLine(inquiry.Value as InquiryDTO); - } - + } + void SearchParagraphById() { Console.WriteLine("\nVeuillez saisir l'identifiant du paragraphe recherché : "); @@ -190,8 +190,8 @@ using (var context = new UserDbContext(options)) } Console.WriteLine(paragraph.Value as ParagraphDTO); - } - + } + void SearchSuccessByInquiryId() { Console.WriteLine("\nVeuillez saisir l'identifiant de l'enquête du succès recherché : "); @@ -204,8 +204,8 @@ using (var context = new UserDbContext(options)) } Console.WriteLine(success.Value as SuccessDTO); - } - + } + void SearchLessonById() { Console.WriteLine("\nVeuillez saisir l'identifiant de la leçon recherchée : "); @@ -229,10 +229,10 @@ using (var context = new UserDbContext(options)) Console.WriteLine("Veuillez saisir un mot de passe :"); var mdp = Console.ReadLine(); var res = userController.CreateUser(new UserDTO(username, mdp, email, false)); - if (res.GetType() == typeof(CreatedResult)) + if (res.GetType() == typeof(CreatedResult)) { Console.WriteLine("\nUtilisateur créé avec succès"); - } + } else { Console.WriteLine("\nErreur lors de la création de l'utilisateur !"); @@ -252,7 +252,7 @@ using (var context = new UserDbContext(options)) var database = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Veuillez saisir l'id de la solution :"); var solution = Convert.ToInt32(Console.ReadLine()); - var res = inquiryController.CreateInquiry(new InquiryDTO(title, description, false, database, solution)); + var res = inquiryController.CreateInquiry(new InquiryDTO(title, description, false)); if (res.GetType() == typeof(CreatedResult)) { Console.WriteLine("\nEnquête créée avec succès"); @@ -261,8 +261,8 @@ using (var context = new UserDbContext(options)) { Console.WriteLine("\nErreur lors de la création de l'enquête !"); } - } - + } + void AddParagraph() { Console.WriteLine("Veuillez saisir le titre :"); @@ -278,17 +278,17 @@ using (var context = new UserDbContext(options)) Console.WriteLine("Veuillez saisir l'id de la leçon :"); var lesson = Convert.ToInt32(Console.ReadLine()); var res = paragraphController.CreateParagraph(new ParagraphDTO(title, content, info, query, comment, lesson)); - if (res.GetType() == typeof(CreatedResult)) + if (res.GetType() == typeof(CreatedResult)) { Console.WriteLine("\nParagraphe créé avec succès"); - } + } else { Console.WriteLine("\nErreur lors de la création du paragraphe !"); } - } - + } + void AddLesson() { Console.WriteLine("Veuillez saisir le titre :"); @@ -296,17 +296,17 @@ using (var context = new UserDbContext(options)) Console.WriteLine("Veuillez saisir votre nom :"); var lastPublisher = Console.ReadLine(); var res = lessonController.CreateLesson(new LessonDTO(title, lastPublisher, DateOnly.FromDateTime(DateTime.Now))); - if (res.GetType() == typeof(CreatedResult)) + if (res.GetType() == typeof(CreatedResult)) { Console.WriteLine("\nLeçon créée avec succès"); - } + } else { Console.WriteLine("\nErreur lors de la création de la leçon !"); } - } - + } + void AddSuccess() { Console.WriteLine("Veuillez saisir l'identifiant de l'utilisateur lié au succès :"); @@ -316,10 +316,10 @@ using (var context = new UserDbContext(options)) Console.WriteLine("Veuillez indiquer si l'enquête a été complété (true/false) :"); var isFinished = Console.ReadLine(); var res = successController.CreateSuccess(new SuccessDTO(int.Parse(userId), int.Parse(inquiryId), bool.Parse(isFinished))); - if (res.GetType() == typeof(CreatedResult)) + if (res.GetType() == typeof(CreatedResult)) { Console.WriteLine("\nSuccès créé avec succès"); - } + } else { Console.WriteLine("\nErreur lors de la création du succès !"); @@ -331,11 +331,11 @@ using (var context = new UserDbContext(options)) { Console.WriteLine("Quel est l'identifiant de l'utilisateur à mettre à jour ?"); var id = int.Parse(Console.ReadLine()); - var res = (await userController.GetUserById(id)); - if (res.GetType() == typeof(OkObjectResult)) + var res = (userController.GetUserById(id)); + if (res.GetType() == typeof(OkObjectResult)) { - var user = (res as OkObjectResult).Value as UserDTO; - if (user == null) + var user = (await res as OkObjectResult).Value as UserDTO; + if (user == null) { Console.WriteLine("Erreur, un problème est survenu"); return; @@ -351,29 +351,29 @@ using (var context = new UserDbContext(options)) if (retour.GetType() == typeof(OkObjectResult)) { Console.WriteLine("Mise à jour effectué avec succès !"); - } + } else { Console.WriteLine("Une erreur est survenue lors de la mise à jour."); } } - } - else + } + else { Console.WriteLine("Une erreur est survenue lors de la mise à jour !"); } - } - + } + void UpdateInquiry() { Console.WriteLine("Quel est l'identifiant de l'enquête à mettre à jour ?"); var id = int.Parse(Console.ReadLine()); var res = (inquiryController.GetInquiryById(id)); - if (res.GetType() == typeof(OkObjectResult)) + if (res.GetType() == typeof(OkObjectResult)) { var user = (res as OkObjectResult).Value as InquiryDTO; - if (user == null) + if (user == null) { Console.WriteLine("Erreur, un problème est survenu"); return; @@ -387,37 +387,37 @@ using (var context = new UserDbContext(options)) var description = Console.ReadLine(); Console.WriteLine("Veuillez indiquer si l'enquête est accessible aux visiteurs (0/1) :"); var isUser = Console.ReadLine(); - Console.WriteLine("Veuillez saisir un commentaire :"); + Console.WriteLine("Veuillez saisir un commentaire :"); var database = Convert.ToInt32(Console.ReadLine()); - Console.WriteLine("Veuillez saisir un commentaire :"); + Console.WriteLine("Veuillez saisir un commentaire :"); var inquiryTable = Convert.ToInt32(Console.ReadLine()); - var retour = inquiryController.UpdateInquiry(id, new InquiryDTO(id, title, description, bool.Parse(isUser), database, inquiryTable)); + var retour = inquiryController.UpdateInquiry(id, new InquiryDTO(id, title, description, bool.Parse(isUser))); if (retour.GetType() == typeof(OkObjectResult)) { Console.WriteLine("Mise à jour effectué avec succès !"); - } + } else { Console.WriteLine("Une erreur est survenue lors de la mise à jour."); } } - } - else + } + else { Console.WriteLine("Une erreur est survenue lors de la mise à jour !"); } - } - + } + void UpdateParagraph() { Console.WriteLine("Quel est l'identifiant du paragraphe à mettre à jour ?"); var id = int.Parse(Console.ReadLine()); var res = (paragraphController.GetParagraphById(id)); - if (res.GetType() == typeof(OkObjectResult)) + if (res.GetType() == typeof(OkObjectResult)) { var paragraph = (res as OkObjectResult).Value as ParagraphDTO; - if (paragraph == null) + if (paragraph == null) { Console.WriteLine("Erreur, un problème est survenu"); return; @@ -435,35 +435,35 @@ using (var context = new UserDbContext(options)) var query = Console.ReadLine(); Console.WriteLine("Veuillez saisir un commentaire :"); var comment = Console.ReadLine(); - Console.WriteLine("Veuillez saisir l'id de la leçon :"); + Console.WriteLine("Veuillez saisir l'id de la leçon :"); var lesson = Convert.ToInt32(Console.ReadLine()); var retour = paragraphController.UpdateParagraph(id, new ParagraphDTO(id, title, content, info, query, comment, lesson)); if (retour.GetType() == typeof(OkObjectResult)) { Console.WriteLine("Mise à jour effectué avec succès !"); - } + } else { Console.WriteLine("Une erreur est survenue lors de la mise à jour."); } } - } - else + } + else { Console.WriteLine("Une erreur est survenue lors de la mise à jour !"); } - } - + } + void UpdateLesson() { Console.WriteLine("Quel est l'identifiant de la leçon à mettre à jour ?"); var id = int.Parse(Console.ReadLine()); var res = (lessonController.GetLessonById(id)); - if (res.GetType() == typeof(OkObjectResult)) + if (res.GetType() == typeof(OkObjectResult)) { var lesson = (res as OkObjectResult).Value as LessonDTO; - if (lesson == null) + if (lesson == null) { Console.WriteLine("Erreur, un problème est survenu"); return; @@ -479,29 +479,29 @@ using (var context = new UserDbContext(options)) if (retour.GetType() == typeof(OkObjectResult)) { Console.WriteLine("Mise à jour effectué avec succès !"); - } + } else { Console.WriteLine("Une erreur est survenue lors de la mise à jour."); } } - } - else + } + else { Console.WriteLine("Une erreur est survenue lors de la mise à jour !"); } - } - + } + void UpdateSuccess() { Console.WriteLine("Quel est l'identifiant de l'utilisateur lié au succès à mettre à jour ?"); var id = int.Parse(Console.ReadLine()); var res = (successController.GetSuccessByUserId(id)); - if (res.GetType() == typeof(OkObjectResult)) + if (res.GetType() == typeof(OkObjectResult)) { var lesson = (res as OkObjectResult).Value as SuccessDTO; - if (lesson == null) + if (lesson == null) { Console.WriteLine("Erreur, un problème est survenu"); return; @@ -519,14 +519,14 @@ using (var context = new UserDbContext(options)) if (retour.GetType() == typeof(OkObjectResult)) { Console.WriteLine("Mise à jour effectué avec succès !"); - } + } else { Console.WriteLine("Une erreur est survenue lors de la mise à jour."); } } - } - else + } + else { Console.WriteLine("Une erreur est survenue lors de la mise à jour !"); } @@ -578,8 +578,8 @@ using (var context = new UserDbContext(options)) Console.WriteLine("Erreur lors de la suppression !"); } - } - + } + void DeleteLesson() { Console.WriteLine("Quel est l'identifiant de la leçon à supprimer ?"); @@ -594,8 +594,8 @@ using (var context = new UserDbContext(options)) Console.WriteLine("Erreur lors de la suppression !"); } - } - + } + void DeleteSuccess() { Console.WriteLine("Quel est l'identifiant de l'utilisateur lié au succès à supprimer ?"); @@ -641,8 +641,8 @@ using (var context = new UserDbContext(options)) Console.WriteLine("| 6 - Supprimer une enquête |"); Console.WriteLine("| q - Quitter |"); Console.WriteLine("|------------------------------------------------|"); - } - + } + void MenuParagraphs() { Console.WriteLine("|------------------------------------------------|"); @@ -656,8 +656,8 @@ using (var context = new UserDbContext(options)) Console.WriteLine("| 6 - Supprimer un paragraphe |"); Console.WriteLine("| q - Quitter |"); Console.WriteLine("|------------------------------------------------|"); - } - + } + void MenuLessons() { Console.WriteLine("|------------------------------------------------|"); @@ -671,8 +671,8 @@ using (var context = new UserDbContext(options)) Console.WriteLine("| 6 - Supprimer une leçon |"); Console.WriteLine("| q - Quitter |"); Console.WriteLine("|------------------------------------------------|"); - } - + } + void MenuSuccesses() { Console.WriteLine("|------------------------------------------------|"); @@ -696,7 +696,7 @@ using (var context = new UserDbContext(options)) Console.WriteLine("\nSaisie :"); var saisie = Console.ReadLine(); - while (saisie != "q") + while (saisie != "q") { switch (saisie) { @@ -773,8 +773,8 @@ using (var context = new UserDbContext(options)) else { var users = res as IEnumerable; - if (users == null) - { + if (users == null) + { Console.WriteLine("\nErreur, les ustilisateurs n'ont pas été trouvés !"); } else diff --git a/API_SQLuedo/TestConsoleEf/Program.cs b/API_SQLuedo/TestConsoleEf/Program.cs index c32e2fa..fb63a8f 100644 --- a/API_SQLuedo/TestConsoleEf/Program.cs +++ b/API_SQLuedo/TestConsoleEf/Program.cs @@ -164,7 +164,7 @@ using (var db = new StubbedContext(options)) Console.WriteLine(sol.MurdererFirstName); var inquirySolution = await inquiries.FirstOrDefaultAsync(i => i.Title == "L'enquête sur les orang outan"); - var i = inquirySolution.InquiryTable; + var i = inquirySolution.Id; foreach (var pptt in typeof(SolutionEntity).GetProperties() .Where(p => p.CanWrite && p.Name != nameof(SolutionEntity.Owner))) { @@ -176,9 +176,7 @@ using (var db = new StubbedContext(options)) var newInquiry = new InquiryEntity( "La nouvelle enquete", "La description de la nouvelle enquete", - true, - null, - null); + true); if (!inquiries.Any(inquiry => inquiry.Title == newInquiry.Title)) { inquiries.Add(newInquiry);