From 0c936e14eccbfee5685d185ac34bbc8c95b62a5f Mon Sep 17 00:00:00 2001 From: masapountz Date: Sun, 25 Feb 2024 12:26:21 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20de=20tous=20des=20mappers=20corresponda?= =?UTF-8?q?nt=20=C3=A0=20chaque=20classe+=20Ajout=20de=20constructeur=20n?= =?UTF-8?q?=C3=A9cessaire=20=C3=A0=20la=20transformation=20+=20Suppression?= =?UTF-8?q?=20des=20propri=C3=A9t=C3=A9s=20de=20navigation=20dans=20les=20?= =?UTF-8?q?DTO=20et=20les=20Business=20classes.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SQLuedoDB/ContentLessonEntity.cs | 9 ++++ .../SQLuedoDB/InquiryEntity.cs | 4 ++ .../SQLuedoDB/InquiryTableEntity.cs | 5 +++ .../EntityFramework/SQLuedoDB/LessonEntity.cs | 15 ++++--- .../SQLuedoDB/ParagraphEntity.cs | 6 +++ .../SQLuedoDB/SolutionEntity.cs | 20 +++++---- .../SQLuedoDB/SuccessEntity.cs | 9 ++++ .../EntityFramework/SQLuedoDB/UserEntity.cs | 5 +++ API_SQLuedo/Model/Business/ContentLesson.cs | 22 ++++++++++ API_SQLuedo/Model/Business/Inquiry.cs | 8 ++-- API_SQLuedo/Model/Business/InquiryTable.cs | 9 +--- API_SQLuedo/Model/Business/Lesson.cs | 15 ++++--- API_SQLuedo/Model/Business/Notepad.cs | 34 ++++++++++++++ API_SQLuedo/Model/Business/Paragraph.cs | 15 ++++--- API_SQLuedo/Model/Business/Solution.cs | 9 ++-- API_SQLuedo/Model/Business/Success.cs | 26 +++++++++++ API_SQLuedo/Model/DTO/ContentLessonDTO.cs | 22 ++++++++++ API_SQLuedo/Model/DTO/InquiryDTO.cs | 6 +-- API_SQLuedo/Model/DTO/InquiryTableDTO.cs | 5 +-- API_SQLuedo/Model/DTO/LessonDTO.cs | 10 ++--- API_SQLuedo/Model/DTO/NotepadDTO.cs | 32 ++++++++++++++ API_SQLuedo/Model/DTO/SolutionDTO.cs | 7 +-- API_SQLuedo/Model/DTO/SuccessDTO.cs | 24 ++++++++++ API_SQLuedo/Model/Mappers/BlackListMapper.cs | 4 +- .../Model/Mappers/ContentLessonMapper.cs | 38 ++++++++++++++++ API_SQLuedo/Model/Mappers/InquiryMapper.cs | 15 +++---- .../Model/Mappers/InquiryTableMapper.cs | 6 +-- API_SQLuedo/Model/Mappers/LessonMapper.cs | 5 ++- API_SQLuedo/Model/Mappers/NotepadMapper.cs | 44 +++++++++++++++++++ API_SQLuedo/Model/Mappers/ParagraphMapper.cs | 34 +++++++++++++- API_SQLuedo/Model/Mappers/SolutionMapper.cs | 14 +++--- API_SQLuedo/Model/Mappers/SuccessMapper.cs | 44 +++++++++++++++++++ API_SQLuedo/Model/Mappers/UserMapper.cs | 2 +- 33 files changed, 440 insertions(+), 83 deletions(-) create mode 100644 API_SQLuedo/Model/Business/ContentLesson.cs create mode 100644 API_SQLuedo/Model/Business/Notepad.cs create mode 100644 API_SQLuedo/Model/Business/Success.cs create mode 100644 API_SQLuedo/Model/DTO/ContentLessonDTO.cs create mode 100644 API_SQLuedo/Model/DTO/NotepadDTO.cs create mode 100644 API_SQLuedo/Model/DTO/SuccessDTO.cs create mode 100644 API_SQLuedo/Model/Mappers/ContentLessonMapper.cs create mode 100644 API_SQLuedo/Model/Mappers/NotepadMapper.cs create mode 100644 API_SQLuedo/Model/Mappers/SuccessMapper.cs diff --git a/API_SQLuedo/EntityFramework/SQLuedoDB/ContentLessonEntity.cs b/API_SQLuedo/EntityFramework/SQLuedoDB/ContentLessonEntity.cs index d352c7b..2778c16 100644 --- a/API_SQLuedo/EntityFramework/SQLuedoDB/ContentLessonEntity.cs +++ b/API_SQLuedo/EntityFramework/SQLuedoDB/ContentLessonEntity.cs @@ -18,5 +18,14 @@ namespace Entities.SQLuedoDB [ForeignKey(nameof(Paragraph))] public int LessonPartId { get; set; } public ParagraphEntity Paragraph { get; set; } + + public ContentLessonEntity(){} + public ContentLessonEntity(int lessonId, LessonEntity lesson, int lessonPartId, ParagraphEntity paragraph) + { + LessonId = lessonId; + Lesson = lesson; + LessonPartId = lessonPartId; + Paragraph = paragraph; + } } } diff --git a/API_SQLuedo/EntityFramework/SQLuedoDB/InquiryEntity.cs b/API_SQLuedo/EntityFramework/SQLuedoDB/InquiryEntity.cs index ed15696..4d73630 100644 --- a/API_SQLuedo/EntityFramework/SQLuedoDB/InquiryEntity.cs +++ b/API_SQLuedo/EntityFramework/SQLuedoDB/InquiryEntity.cs @@ -16,6 +16,10 @@ namespace Entities.SQLuedoDB public SolutionEntity InquiryTable { get; set; } public InquiryEntity() { } + public InquiryEntity(int id) + { + Id = id; + } public InquiryEntity(int id, string title, string description, bool isUser, InquiryTableEntity database, SolutionEntity inquiryTable) { Id = id; diff --git a/API_SQLuedo/EntityFramework/SQLuedoDB/InquiryTableEntity.cs b/API_SQLuedo/EntityFramework/SQLuedoDB/InquiryTableEntity.cs index d9ee75f..155398b 100644 --- a/API_SQLuedo/EntityFramework/SQLuedoDB/InquiryTableEntity.cs +++ b/API_SQLuedo/EntityFramework/SQLuedoDB/InquiryTableEntity.cs @@ -15,6 +15,11 @@ namespace Entities.SQLuedoDB public string ConnectionInfo { get; set; } public InquiryTableEntity() { } + + public InquiryTableEntity(int inquiryId) + { + OwnerId = inquiryId; + } public InquiryTableEntity(int inquiryId, string databaseName, string connectionInfo) { OwnerId = inquiryId; diff --git a/API_SQLuedo/EntityFramework/SQLuedoDB/LessonEntity.cs b/API_SQLuedo/EntityFramework/SQLuedoDB/LessonEntity.cs index 1f3bff3..623eb1b 100644 --- a/API_SQLuedo/EntityFramework/SQLuedoDB/LessonEntity.cs +++ b/API_SQLuedo/EntityFramework/SQLuedoDB/LessonEntity.cs @@ -9,12 +9,17 @@ namespace Entities.SQLuedoDB public class LessonEntity { public int Id { get; set; } - public string Title { get; set; } - public string LastPublisher { get; set; } - public DateOnly LastEdit { get; set; } + public string? Title { get; set; } + public string? LastPublisher { get; set; } + public DateOnly? LastEdit { get; set; } public LessonEntity() { } - public LessonEntity(int id, string title, string lastPublisher, DateOnly lastEdit) + + public LessonEntity(int id) + { + Id = id; + } + public LessonEntity(int id, string title, string lastPublisher, DateOnly? lastEdit) { Id = id; Title = title; @@ -22,7 +27,7 @@ namespace Entities.SQLuedoDB LastEdit = lastEdit; } - public LessonEntity(string title, string lastPublisher, DateOnly lastEdit) + public LessonEntity(string title, string lastPublisher, DateOnly? lastEdit) { Title = title; LastPublisher = lastPublisher; diff --git a/API_SQLuedo/EntityFramework/SQLuedoDB/ParagraphEntity.cs b/API_SQLuedo/EntityFramework/SQLuedoDB/ParagraphEntity.cs index 996dc88..d83e27c 100644 --- a/API_SQLuedo/EntityFramework/SQLuedoDB/ParagraphEntity.cs +++ b/API_SQLuedo/EntityFramework/SQLuedoDB/ParagraphEntity.cs @@ -11,6 +11,12 @@ public ParagraphEntity() { } + + public ParagraphEntity(int id) + { + Id = id; + } + public ParagraphEntity(int id, string title, string content, string info, string query, string comment) { Id = id; diff --git a/API_SQLuedo/EntityFramework/SQLuedoDB/SolutionEntity.cs b/API_SQLuedo/EntityFramework/SQLuedoDB/SolutionEntity.cs index f7df58e..15879f7 100644 --- a/API_SQLuedo/EntityFramework/SQLuedoDB/SolutionEntity.cs +++ b/API_SQLuedo/EntityFramework/SQLuedoDB/SolutionEntity.cs @@ -11,14 +11,18 @@ namespace Entities.SQLuedoDB [DatabaseGenerated(DatabaseGeneratedOption.Identity)] [Required] public int OwnerId { get; set; } - public InquiryEntity Owner { get; set; } - public string MurdererFirstName { get; set; } - public string MurdererLastName { get; set; } - public string MurderPlace { get; set; } - public string MurderWeapon { get; set; } - public string Explanation { get; set; } + public InquiryEntity? Owner { get; set; } + public string? MurdererFirstName { get; set; } + public string? MurdererLastName { get; set; } + public string? MurderPlace { get; set; } + public string? MurderWeapon { get; set; } + public string? Explanation { get; set; } public SolutionEntity() { } - public SolutionEntity(int ownerId, InquiryEntity owner, string murdererFirstName, string murdererLastName, string murderPlace, string murderWeapon, string explanation) + public SolutionEntity(int ownerId) + { + OwnerId = ownerId; + } + public SolutionEntity(int ownerId, InquiryEntity? owner, string murdererFirstName, string murdererLastName, string murderPlace, string murderWeapon, string explanation) { OwnerId = ownerId; Owner = owner; @@ -28,7 +32,7 @@ namespace Entities.SQLuedoDB MurderWeapon = murderWeapon; Explanation = explanation; } - public SolutionEntity(InquiryEntity owner, string murdererFirstName, string murdererLastName, string murderPlace, string murderWeapon, string explanation) + public SolutionEntity(InquiryEntity? owner, string murdererFirstName, string murdererLastName, string murderPlace, string murderWeapon, string explanation) { Owner = owner; MurdererFirstName = murdererFirstName; diff --git a/API_SQLuedo/EntityFramework/SQLuedoDB/SuccessEntity.cs b/API_SQLuedo/EntityFramework/SQLuedoDB/SuccessEntity.cs index 498286a..4c06815 100644 --- a/API_SQLuedo/EntityFramework/SQLuedoDB/SuccessEntity.cs +++ b/API_SQLuedo/EntityFramework/SQLuedoDB/SuccessEntity.cs @@ -21,6 +21,15 @@ namespace Entities.SQLuedoDB public SuccessEntity() { } + public SuccessEntity(int userId, UserEntity user, int inquiryId, InquiryEntity inquiry, bool isFinished) + { + UserId = userId; + User = user; + InquiryId = inquiryId; + Inquiry = inquiry; + IsFinished = isFinished; + } + public SuccessEntity(int userId, int inquiryId, bool isFinished) { UserId = userId; diff --git a/API_SQLuedo/EntityFramework/SQLuedoDB/UserEntity.cs b/API_SQLuedo/EntityFramework/SQLuedoDB/UserEntity.cs index 82f168b..2de5210 100644 --- a/API_SQLuedo/EntityFramework/SQLuedoDB/UserEntity.cs +++ b/API_SQLuedo/EntityFramework/SQLuedoDB/UserEntity.cs @@ -13,6 +13,11 @@ namespace Entities.SQLuedoDB public UserEntity() { } + public UserEntity(int id) + { + Id = id; + } + public UserEntity(int id, string username, string password, string email, bool isAdmin) { Id = id; diff --git a/API_SQLuedo/Model/Business/ContentLesson.cs b/API_SQLuedo/Model/Business/ContentLesson.cs new file mode 100644 index 0000000..22494db --- /dev/null +++ b/API_SQLuedo/Model/Business/ContentLesson.cs @@ -0,0 +1,22 @@ +using Entities.SQLuedoDB; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Model.Business +{ + public class ContentLesson + { + public ContentLesson(int lessonId, int lessonPartId) + { + LessonId = lessonId; + LessonPartId = lessonPartId; + } + + public int LessonId { get; set; } + public int LessonPartId { get; set; } + } +} diff --git a/API_SQLuedo/Model/Business/Inquiry.cs b/API_SQLuedo/Model/Business/Inquiry.cs index 77c8fe0..316e8eb 100644 --- a/API_SQLuedo/Model/Business/Inquiry.cs +++ b/API_SQLuedo/Model/Business/Inquiry.cs @@ -1,4 +1,4 @@ -using Entities.SQLudeoDB; +using Entities.SQLuedoDB; using System; using System.Collections.Generic; using System.Globalization; @@ -14,12 +14,12 @@ namespace Model.Business public string Title { get; set; } public string Description { get; set; } public bool IsUser { get; set; } - public InquiryTable Database { get; set; } - public Solution InquiryTable { get; set; } + public int Database { get; set; } + public int InquiryTable { get; set; } public Inquiry() { } - public Inquiry(int id, string title, string description, bool isUser, InquiryTable database, Solution inquiryTable) + public Inquiry(int id, string title, string description, bool isUser, int database, int inquiryTable) { Id = id; Title = title; diff --git a/API_SQLuedo/Model/Business/InquiryTable.cs b/API_SQLuedo/Model/Business/InquiryTable.cs index 99b1169..d8ac992 100644 --- a/API_SQLuedo/Model/Business/InquiryTable.cs +++ b/API_SQLuedo/Model/Business/InquiryTable.cs @@ -1,4 +1,4 @@ -using Entities.SQLudeoDB; +using Entities.SQLuedoDB; using System; using System.Collections.Generic; using System.Linq; @@ -10,7 +10,6 @@ namespace Model.Business public class InquiryTable { public int OwnerId { get; set; } - public Inquiry Owner { get; set; } public string DatabaseName { get; set; } public string ConnectionInfo { get; set; } @@ -22,11 +21,5 @@ namespace Model.Business ConnectionInfo = connectionInfo; } - public InquiryTable(Inquiry owner, string databaseName, string connectionInfo) - { - Owner = owner; - DatabaseName = databaseName; - ConnectionInfo = connectionInfo; - } } } diff --git a/API_SQLuedo/Model/Business/Lesson.cs b/API_SQLuedo/Model/Business/Lesson.cs index de2d9a0..2e2121d 100644 --- a/API_SQLuedo/Model/Business/Lesson.cs +++ b/API_SQLuedo/Model/Business/Lesson.cs @@ -9,12 +9,17 @@ namespace Model.Business public class Lesson { public int Id { get; } - public string Title { get; set; } - public string LastPublisher { get; set; } - public DateOnly LastEdit { get; set; } + public string? Title { get; set; } + public string? LastPublisher { get; set; } + public DateOnly? LastEdit { get; set; } public Lesson() { } - public Lesson(int id, string title, string lastPublisher, DateOnly lastEdit) + + public Lesson(int id) + { + Id = id; + } + public Lesson(int id, string title, string lastPublisher, DateOnly? lastEdit) { Id = id; Title = title; @@ -22,7 +27,7 @@ namespace Model.Business LastEdit = lastEdit; } - public Lesson(string title, string lastPublisher, DateOnly lastEdit) + public Lesson(string title, string lastPublisher, DateOnly? lastEdit) { Title = title; LastPublisher = lastPublisher; diff --git a/API_SQLuedo/Model/Business/Notepad.cs b/API_SQLuedo/Model/Business/Notepad.cs new file mode 100644 index 0000000..177a1d3 --- /dev/null +++ b/API_SQLuedo/Model/Business/Notepad.cs @@ -0,0 +1,34 @@ +using Entities.SQLuedoDB; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Model.Business +{ + public class Notepad + { + public int Id { get; set; } + public int UserId { get; set; } + public int InquiryId { get; set; } + public string Notes { get; set; } + + public Notepad() { } + + public Notepad(int id, int userId, int inquiryId, string notes) + { + Id = id; + UserId = userId; + InquiryId = inquiryId; + Notes = notes; + } + public Notepad(int userId, int inquiryId, string notes) + { + UserId = userId; + InquiryId = inquiryId; + Notes = notes; + } + } +} diff --git a/API_SQLuedo/Model/Business/Paragraph.cs b/API_SQLuedo/Model/Business/Paragraph.cs index f33b5bc..0edb9df 100644 --- a/API_SQLuedo/Model/Business/Paragraph.cs +++ b/API_SQLuedo/Model/Business/Paragraph.cs @@ -9,14 +9,19 @@ namespace Model.Business public class Paragraph { public int Id { get; } - public string Title { get; set; } - public string Content { get; set; } - public string Info { get; set; } - public string Query { get; set; } - public string Comment { get; set; } + public string? Title { get; set; } + public string? Content { get; set; } + public string? Info { get; set; } + public string? Query { get; set; } + public string? Comment { get; set; } public Paragraph() { } + public Paragraph(int id) + { + Id = id; + } + public Paragraph(int id, string title, string content, string info, string query, string comment) { Id = id; diff --git a/API_SQLuedo/Model/Business/Solution.cs b/API_SQLuedo/Model/Business/Solution.cs index d09b7e7..4835fa5 100644 --- a/API_SQLuedo/Model/Business/Solution.cs +++ b/API_SQLuedo/Model/Business/Solution.cs @@ -1,4 +1,4 @@ -using Entities.SQLudeoDB; +using Entities.SQLuedoDB; using System; using System.Collections.Generic; using System.Linq; @@ -10,26 +10,23 @@ namespace Model.Business public class Solution { public int OwnerId { get; set; } - public Inquiry Owner { get; set; } public string MurdererFirstName { get; set; } public string MurdererLastName { get; set; } public string MurderPlace { get; set; } public string MurderWeapon { get; set; } public string Explanation { get; set; } public Solution() { } - public Solution(int ownerId, Inquiry owner, string murdererFirstName, string murdererLastName, string murderPlace, string murderWeapon, string explanation) + public Solution(int ownerId, string murdererFirstName, string murdererLastName, string murderPlace, string murderWeapon, string explanation) { OwnerId = ownerId; - Owner = owner; MurdererFirstName = murdererFirstName; MurdererLastName = murdererLastName; MurderPlace = murderPlace; MurderWeapon = murderWeapon; Explanation = explanation; } - public Solution(Inquiry owner, string murdererFirstName, string murdererLastName, string murderPlace, string murderWeapon, string explanation) + public Solution(string murdererFirstName, string murdererLastName, string murderPlace, string murderWeapon, string explanation) { - Owner = owner; MurdererFirstName = murdererFirstName; MurdererLastName = murdererLastName; MurderPlace = murderPlace; diff --git a/API_SQLuedo/Model/Business/Success.cs b/API_SQLuedo/Model/Business/Success.cs new file mode 100644 index 0000000..6e8ff28 --- /dev/null +++ b/API_SQLuedo/Model/Business/Success.cs @@ -0,0 +1,26 @@ +using Entities.SQLuedoDB; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Model.Business +{ + public class Success + { + public int UserId { get; set; } + public int InquiryId { get; set; } + public bool IsFinished { get; set; } + + public Success() { } + + public Success(int userId, int inquiryId, bool isFinished) + { + UserId = userId; + InquiryId = inquiryId; + IsFinished = isFinished; + } + } +} diff --git a/API_SQLuedo/Model/DTO/ContentLessonDTO.cs b/API_SQLuedo/Model/DTO/ContentLessonDTO.cs new file mode 100644 index 0000000..966509c --- /dev/null +++ b/API_SQLuedo/Model/DTO/ContentLessonDTO.cs @@ -0,0 +1,22 @@ +using Entities.SQLuedoDB; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Model.Business +{ + public class ContentLessonDTO + { + public int LessonId { get; set; } + public int LessonPartId { get; set; } + + public ContentLessonDTO(int lessonId, int lessonPartId) + { + LessonId = lessonId; + LessonPartId = lessonPartId; + } + } +} \ No newline at end of file diff --git a/API_SQLuedo/Model/DTO/InquiryDTO.cs b/API_SQLuedo/Model/DTO/InquiryDTO.cs index 4fac705..0b87c5f 100644 --- a/API_SQLuedo/Model/DTO/InquiryDTO.cs +++ b/API_SQLuedo/Model/DTO/InquiryDTO.cs @@ -17,10 +17,10 @@ namespace Model.DTO public bool IsUser { get; set; } - public InquiryTableDTO Database { get; set; } - public SolutionDTO InquiryTable { get; set; } + public int Database { get; set; } + public int InquiryTable { get; set; } - public InquiryDTO(int id, string title, string description, bool isUser, InquiryTableDTO database, SolutionDTO inquiryTable) + public InquiryDTO(int id, string title, string description, bool isUser, int database, int inquiryTable) { Id = id; Title = title; diff --git a/API_SQLuedo/Model/DTO/InquiryTableDTO.cs b/API_SQLuedo/Model/DTO/InquiryTableDTO.cs index 20b342f..e08ecda 100644 --- a/API_SQLuedo/Model/DTO/InquiryTableDTO.cs +++ b/API_SQLuedo/Model/DTO/InquiryTableDTO.cs @@ -9,19 +9,16 @@ namespace Model.DTO { public class InquiryTableDTO { - private Inquiry owner; public int OwnerId { get; set; } - public InquiryDTO Owner { get; set; } public string DatabaseName { get; set; } public string ConnectionInfo { get; set; } public InquiryTableDTO() { } - public InquiryTableDTO(int ownerId, InquiryDTO owner, string databaseName, string connectionInfo) + public InquiryTableDTO(int ownerId, string databaseName, string connectionInfo) { OwnerId = ownerId; - Owner = owner; DatabaseName = databaseName; ConnectionInfo = connectionInfo; } diff --git a/API_SQLuedo/Model/DTO/LessonDTO.cs b/API_SQLuedo/Model/DTO/LessonDTO.cs index dfc3351..8680d98 100644 --- a/API_SQLuedo/Model/DTO/LessonDTO.cs +++ b/API_SQLuedo/Model/DTO/LessonDTO.cs @@ -9,12 +9,12 @@ namespace Model.DTO public class LessonDTO { public int Id { get; } - public string Title { get; set; } - public string LastPublisher { get; set; } - public DateOnly LastEdit { get; set; } + public string? Title { get; set; } + public string? LastPublisher { get; set; } + public DateOnly? LastEdit { get; set; } public LessonDTO() { } - public LessonDTO(int id, string title, string lastPublisher, DateOnly lastEdit) + public LessonDTO(int id, string title, string lastPublisher, DateOnly? lastEdit) { Id = id; Title = title; @@ -22,7 +22,7 @@ namespace Model.DTO LastEdit = lastEdit; } - public LessonDTO(string title, string lastPublisher, DateOnly lastEdit) + public LessonDTO(string title, string lastPublisher, DateOnly? lastEdit) { Title = title; LastPublisher = lastPublisher; diff --git a/API_SQLuedo/Model/DTO/NotepadDTO.cs b/API_SQLuedo/Model/DTO/NotepadDTO.cs new file mode 100644 index 0000000..e3fd9c9 --- /dev/null +++ b/API_SQLuedo/Model/DTO/NotepadDTO.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Model.DTO +{ + public class NotepadDTO + { + public int Id { get; set; } + public int UserId { get; set; } + public int InquiryId { get; set; } + public string Notes { get; set; } + + public NotepadDTO() { } + + public NotepadDTO(int id, int userId, int inquiryId, string notes) + { + Id = id; + UserId = userId; + InquiryId = inquiryId; + Notes = notes; + } + public NotepadDTO(int userId, int inquiryId, string notes) + { + UserId = userId; + InquiryId = inquiryId; + Notes = notes; + } + } +} diff --git a/API_SQLuedo/Model/DTO/SolutionDTO.cs b/API_SQLuedo/Model/DTO/SolutionDTO.cs index 7ec656a..50e1e84 100644 --- a/API_SQLuedo/Model/DTO/SolutionDTO.cs +++ b/API_SQLuedo/Model/DTO/SolutionDTO.cs @@ -10,26 +10,23 @@ namespace Model.DTO public class SolutionDTO { public int OwnerId { get; set; } - public InquiryDTO Owner { get; set; } public string MurdererFirstName { get; set; } public string MurdererLastName { get; set; } public string MurderPlace { get; set; } public string MurderWeapon { get; set; } public string Explanation { get; set; } public SolutionDTO() { } - public SolutionDTO(int ownerId, InquiryDTO owner, string murdererFirstName, string murdererLastName, string murderPlace, string murderWeapon, string explanation) + public SolutionDTO(int ownerId, string murdererFirstName, string murdererLastName, string murderPlace, string murderWeapon, string explanation) { OwnerId = ownerId; - Owner = owner; MurdererFirstName = murdererFirstName; MurdererLastName = murdererLastName; MurderPlace = murderPlace; MurderWeapon = murderWeapon; Explanation = explanation; } - public SolutionDTO(InquiryDTO owner, string murdererFirstName, string murdererLastName, string murderPlace, string murderWeapon, string explanation) + public SolutionDTO(string murdererFirstName, string murdererLastName, string murderPlace, string murderWeapon, string explanation) { - Owner = owner; MurdererFirstName = murdererFirstName; MurdererLastName = murdererLastName; MurderPlace = murderPlace; diff --git a/API_SQLuedo/Model/DTO/SuccessDTO.cs b/API_SQLuedo/Model/DTO/SuccessDTO.cs new file mode 100644 index 0000000..924117a --- /dev/null +++ b/API_SQLuedo/Model/DTO/SuccessDTO.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Model.DTO +{ + public class SuccessDTO + { + public int UserId { get; set; } + public int InquiryId { get; set; } + public bool IsFinished { get; set; } + + public SuccessDTO() { } + + public SuccessDTO(int userId, int inquiryId, bool isFinished) + { + UserId = userId; + InquiryId = inquiryId; + IsFinished = isFinished; + } + } +} diff --git a/API_SQLuedo/Model/Mappers/BlackListMapper.cs b/API_SQLuedo/Model/Mappers/BlackListMapper.cs index dc9a5fa..8f6f52d 100644 --- a/API_SQLuedo/Model/Mappers/BlackListMapper.cs +++ b/API_SQLuedo/Model/Mappers/BlackListMapper.cs @@ -3,13 +3,13 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using Entities.SQLudeoDB; +using Entities.SQLuedoDB; using Model.Business; using Model.DTO; namespace Model.Mappers { - public class BlackListMapper + public static class BlackListMapper { public static BlackListDTO FromModelToDTO(BlackList model) { diff --git a/API_SQLuedo/Model/Mappers/ContentLessonMapper.cs b/API_SQLuedo/Model/Mappers/ContentLessonMapper.cs new file mode 100644 index 0000000..f568070 --- /dev/null +++ b/API_SQLuedo/Model/Mappers/ContentLessonMapper.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Entities.SQLuedoDB; +using Model.Business; + +namespace Model.Mappers +{ + public static class ContentLessonMapper + { + public static ContentLesson FromDTOToModel(this ContentLessonDTO dto) + { + return new ContentLesson(dto.LessonId, dto.LessonPartId); + } + + public static ContentLesson FromEntityToModel(this ContentLessonEntity ent) + { + return new ContentLesson(ent.LessonId, ent.LessonPartId); + } + + public static ContentLessonDTO FromModelToDTO(this ContentLesson les) + { + return new ContentLessonDTO(les.LessonId, les.LessonPartId); + } + + public static ContentLessonDTO FromEntityToDTO(this ContentLessonEntity ent) + { + return new ContentLessonDTO(ent.LessonId, ent.LessonPartId); + } + + public static ContentLessonEntity FromModelToEntity(this ContentLesson les) + { + return new ContentLessonEntity(les.LessonId,new LessonEntity(les.LessonId),les.LessonPartId,new ParagraphEntity(les.LessonPartId)); + } + } +} diff --git a/API_SQLuedo/Model/Mappers/InquiryMapper.cs b/API_SQLuedo/Model/Mappers/InquiryMapper.cs index 65df083..a26ef45 100644 --- a/API_SQLuedo/Model/Mappers/InquiryMapper.cs +++ b/API_SQLuedo/Model/Mappers/InquiryMapper.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using Entities.SQLudeoDB; +using Entities.SQLuedoDB; using Model.Business; using Model.DTO; @@ -13,32 +13,31 @@ namespace Model.Mappers { public static Inquiry FromDTOToModel(this InquiryDTO InqDto) { - return new Inquiry(InqDto.Id,InqDto.Title,InqDto.Description,InqDto.IsUser,InqDto.Database.FromDTOToModel(),InqDto.InquiryTable.FromDTOToModel()); + return new Inquiry(InqDto.Id,InqDto.Title,InqDto.Description,InqDto.IsUser,InqDto.Database,InqDto.InquiryTable); } public static Inquiry FromEntityToModel(this InquiryEntity InqEntity) { - return new Inquiry(InqEntity.Id, InqEntity.Title, InqEntity.Description, InqEntity.IsUser, InqEntity.Database.FromEntityToModel(), InqEntity.InquiryTable.FromEntityToModel()); + return new Inquiry(InqEntity.Id, InqEntity.Title, InqEntity.Description, InqEntity.IsUser, InqEntity.Database.OwnerId, InqEntity.InquiryTable.OwnerId); } public static InquiryEntity FromModelToEntity(this Inquiry Inq) { - return new InquiryEntity(Inq.Id, Inq.Title, Inq.Description, Inq.IsUser, Inq.Database.FromModelToEntity(), Inq.InquiryTable.FromModelToEntity()); + return new InquiryEntity(Inq.Id, Inq.Title, Inq.Description, Inq.IsUser,new InquiryTableEntity(Inq.Database),new SolutionEntity(Inq.InquiryTable)); } - public static InquiryEntity FromDTOToEntity(this InquiryDTO InqDto) { - return new InquiryEntity(InqDto.Id, InqDto.Title, InqDto.Description, InqDto.IsUser, InqDto.Database.FromDTOToEntity(), InqDto.InquiryTable.FromDTOToEntity()); + return new InquiryEntity(InqDto.Id, InqDto.Title, InqDto.Description, InqDto.IsUser, new InquiryTableEntity(InqDto.Database), new SolutionEntity(InqDto.InquiryTable)); } public static InquiryDTO FromModelToDTO(this Inquiry Inq) { - return new InquiryDTO(Inq.Id, Inq.Title, Inq.Description, Inq.IsUser, Inq.Database.FromModelToDTO(), Inq.InquiryTable.FromModelToDTO()); + return new InquiryDTO(Inq.Id, Inq.Title, Inq.Description, Inq.IsUser, Inq.Database, Inq.InquiryTable); } public static InquiryDTO FromEntityToDTO(this InquiryEntity InqEntity) { - return new InquiryDTO(InqEntity.Id, InqEntity.Title, InqEntity.Description, InqEntity.IsUser, InqEntity.Database.FromEntityToDTO(), InqEntity.InquiryTable.FromEntityToDTO()); + return new InquiryDTO(InqEntity.Id, InqEntity.Title, InqEntity.Description, InqEntity.IsUser, InqEntity.Database.OwnerId, InqEntity.InquiryTable.OwnerId); } } diff --git a/API_SQLuedo/Model/Mappers/InquiryTableMapper.cs b/API_SQLuedo/Model/Mappers/InquiryTableMapper.cs index 6262326..234aa35 100644 --- a/API_SQLuedo/Model/Mappers/InquiryTableMapper.cs +++ b/API_SQLuedo/Model/Mappers/InquiryTableMapper.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using Entities.SQLudeoDB; +using Entities.SQLuedoDB; namespace Model.Mappers { @@ -23,12 +23,12 @@ namespace Model.Mappers public static InquiryTableDTO FromModelToDTO(this InquiryTable InqT) { - return new InquiryTableDTO(InqT.OwnerId, InqT.Owner.FromModelToDTO(), InqT.DatabaseName, InqT.ConnectionInfo); + return new InquiryTableDTO(InqT.OwnerId, InqT.DatabaseName, InqT.ConnectionInfo); } public static InquiryTableDTO FromEntityToDTO(this InquiryTableEntity InqTEntity) { - return new InquiryTableDTO(InqTEntity.OwnerId, InqTEntity.Owner.FromEntityToDTO(), InqTEntity.DatabaseName, InqTEntity.ConnectionInfo); + return new InquiryTableDTO(InqTEntity.OwnerId, InqTEntity.DatabaseName, InqTEntity.ConnectionInfo); } public static InquiryTableEntity FromModelToEntity(this InquiryTable InqT) diff --git a/API_SQLuedo/Model/Mappers/LessonMapper.cs b/API_SQLuedo/Model/Mappers/LessonMapper.cs index 2463006..1ca4094 100644 --- a/API_SQLuedo/Model/Mappers/LessonMapper.cs +++ b/API_SQLuedo/Model/Mappers/LessonMapper.cs @@ -3,13 +3,13 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using Entities.SQLudeoDB; +using Entities.SQLuedoDB; using Model.Business; using Model.DTO; namespace Model.Mappers { - public class LessonMapper + public static class LessonMapper { public static LessonDTO FromModelToDTO(Lesson model) @@ -43,3 +43,4 @@ namespace Model.Mappers } } } + \ No newline at end of file diff --git a/API_SQLuedo/Model/Mappers/NotepadMapper.cs b/API_SQLuedo/Model/Mappers/NotepadMapper.cs new file mode 100644 index 0000000..f19109b --- /dev/null +++ b/API_SQLuedo/Model/Mappers/NotepadMapper.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Entities.SQLuedoDB; +using Model.Business; +using Model.DTO; + +namespace Model.Mappers +{ + public static class NotepadMapper + { + public static Notepad FromDTOToModel(this NotepadDTO dto) + { + return new Notepad(dto.Id, dto.UserId, dto.InquiryId, dto.Notes); + } + + public static Notepad FromEntityToModel(this NotepadEntity ent) + { + return new Notepad(ent.Id, ent.UserId, ent.InquiryId, ent.Notes); + } + + public static NotepadDTO FromModelToDTO(this Notepad not) + { + return new NotepadDTO(not.Id, not.UserId, not.InquiryId, not.Notes); + } + + public static NotepadDTO FromEntityToDTO(this NotepadEntity ent) + { + return new NotepadDTO(ent.Id, ent.UserId, ent.InquiryId, ent.Notes); + } + + public static NotepadEntity FromDTOToEntity(this NotepadDTO dto) + { + return new NotepadEntity(dto.Id,new UserEntity(dto.UserId), dto.UserId, new InquiryEntity(dto.InquiryId), dto.Notes); + } + + public static NotepadEntity FromModelToEntity(this Notepad not) + { + return new NotepadEntity(not.Id, new UserEntity(not.UserId), not.UserId, new InquiryEntity(not.InquiryId), not.Notes); + } + } +} diff --git a/API_SQLuedo/Model/Mappers/ParagraphMapper.cs b/API_SQLuedo/Model/Mappers/ParagraphMapper.cs index 722184c..5d1928c 100644 --- a/API_SQLuedo/Model/Mappers/ParagraphMapper.cs +++ b/API_SQLuedo/Model/Mappers/ParagraphMapper.cs @@ -3,10 +3,40 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; - +using Entities.SQLuedoDB; +using Model.Business; +using Model.DTO; namespace Model.Mappers { - internal class ParagraphMapper + public static class ParagraphMapper { + public static Paragraph FromDTOToModel(ParagraphDTO dto) + { + return new Paragraph(dto.Id,dto.Title,dto.Content,dto.Info,dto.Query,dto.Comment); + } + + public static Paragraph FromEntityToModel(ParagraphEntity model) + { + return new Paragraph(model.Id, model.Title, model.Content, model.Info, model.Query, model.Comment); + } + public static ParagraphDTO FromEntityToDTO(ParagraphEntity model) + { + return new ParagraphDTO(model.Id, model.Title, model.Content, model.Info, model.Query, model.Comment); + } + + public static ParagraphDTO FromModelToDTO(Paragraph model) + { + return new ParagraphDTO(model.Id, model.Title, model.Content, model.Info, model.Query, model.Comment); + } + + public static ParagraphEntity FromDTOToEntity(ParagraphDTO dto) + { + return new ParagraphEntity(dto.Id, dto.Title, dto.Content, dto.Info, dto.Query, dto.Comment); + } + + public static Paragraph FromModelToEntity(Paragraph model) + { + return new Paragraph(model.Id, model.Title, model.Content, model.Info, model.Query, model.Comment); + } } } diff --git a/API_SQLuedo/Model/Mappers/SolutionMapper.cs b/API_SQLuedo/Model/Mappers/SolutionMapper.cs index affbeef..a464be8 100644 --- a/API_SQLuedo/Model/Mappers/SolutionMapper.cs +++ b/API_SQLuedo/Model/Mappers/SolutionMapper.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using Entities.SQLudeoDB; +using Entities.SQLuedoDB; using Model.Business; using Model.DTO; @@ -13,31 +13,31 @@ namespace Model.Mappers { public static Solution FromDTOToModel(this SolutionDTO dto) { - return new Solution(dto.OwnerId,dto.Owner.FromDTOToModel(),dto.MurdererFirstName,dto.MurdererLastName,dto.MurderPlace,dto.MurderWeapon,dto.Explanation); + return new Solution(dto.OwnerId,dto.MurdererFirstName,dto.MurdererLastName,dto.MurderPlace,dto.MurderWeapon,dto.Explanation); } public static Solution FromEntityToModel(this SolutionEntity entity) { - return new Solution(entity.OwnerId, entity.Owner.FromEntityToModel(), entity.MurdererFirstName, entity.MurdererLastName, entity.MurderPlace, entity.MurderWeapon, entity.Explanation); + return new Solution(entity.OwnerId, entity.MurdererFirstName, entity.MurdererLastName, entity.MurderPlace, entity.MurderWeapon, entity.Explanation); } public static SolutionDTO FromModelToDTO(this Solution model) { - return new SolutionDTO(model.OwnerId, model.Owner.FromModelToDTO(), model.MurdererFirstName, model.MurdererLastName, model.MurderPlace, model.MurderWeapon, model.Explanation); + return new SolutionDTO(model.OwnerId, model.MurdererFirstName, model.MurdererLastName, model.MurderPlace, model.MurderWeapon, model.Explanation); } public static SolutionDTO FromEntityToDTO(this SolutionEntity entity) { - return new SolutionDTO(entity.OwnerId, entity.Owner.FromEntityToDTO(), entity.MurdererFirstName, entity.MurdererLastName, entity.MurderPlace, entity.MurderWeapon, entity.Explanation); + return new SolutionDTO(entity.OwnerId, entity.MurdererFirstName, entity.MurdererLastName, entity.MurderPlace, entity.MurderWeapon, entity.Explanation); } public static SolutionEntity FromModelToEntity(this Solution model) { - return new SolutionEntity(model.OwnerId, model.Owner.FromModelToEntity(), model.MurdererFirstName, model.MurdererLastName, model.MurderPlace, model.MurderWeapon, model.Explanation); + return new SolutionEntity(model.OwnerId, new InquiryEntity(model.OwnerId), model.MurdererFirstName, model.MurdererLastName, model.MurderPlace, model.MurderWeapon, model.Explanation); } public static SolutionEntity FromDTOToEntity(this SolutionDTO dto) { - return new SolutionEntity(dto.OwnerId, dto.Owner.FromDTOToEntity(), dto.MurdererFirstName, dto.MurdererLastName, dto.MurderPlace, dto.MurderWeapon, dto.Explanation); + return new SolutionEntity(dto.OwnerId, new InquiryEntity(dto.OwnerId), dto.MurdererFirstName, dto.MurdererLastName, dto.MurderPlace, dto.MurderWeapon, dto.Explanation); } } } diff --git a/API_SQLuedo/Model/Mappers/SuccessMapper.cs b/API_SQLuedo/Model/Mappers/SuccessMapper.cs new file mode 100644 index 0000000..04f56b3 --- /dev/null +++ b/API_SQLuedo/Model/Mappers/SuccessMapper.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Entities.SQLuedoDB; +using Model.Business; +using Model.DTO; + +namespace Model.Mappers +{ + public static class SuccessMapper + { + public static Success FromDTOToModel(this SuccessDTO dto) + { + return new Success(dto.UserId, dto.InquiryId, dto.IsFinished); + } + + public static Success FromEntityToModel(this SuccessEntity ent) + { + return new Success(ent.UserId, ent.InquiryId, ent.IsFinished); + } + + public static SuccessDTO FromModelToDTO(this Success suc) + { + return new SuccessDTO(suc.UserId, suc.InquiryId, suc.IsFinished); + } + + public static SuccessDTO FromEntityToDTO(this SuccessEntity ent) + { + return new SuccessDTO(ent.UserId, ent.InquiryId, ent.IsFinished); + } + + public static SuccessEntity FromDTOToEntity(this SuccessDTO dto) + { + return new SuccessEntity(dto.UserId,new UserEntity(dto.UserId),dto.InquiryId,new InquiryEntity(dto.InquiryId),dto.IsFinished); + } + + public static SuccessEntity FromModelToEntity(this Success suc) + { + return new SuccessEntity(suc.UserId, new UserEntity(suc.UserId), suc.InquiryId, new InquiryEntity(suc.InquiryId), suc.IsFinished); + } + } +} diff --git a/API_SQLuedo/Model/Mappers/UserMapper.cs b/API_SQLuedo/Model/Mappers/UserMapper.cs index 4dd916b..68d80a0 100644 --- a/API_SQLuedo/Model/Mappers/UserMapper.cs +++ b/API_SQLuedo/Model/Mappers/UserMapper.cs @@ -1,4 +1,4 @@ -using Entities.SQLudeoDB; +using Entities.SQLuedoDB; using Model.Business; using Model.DTO;