Modification des classes Lesson, ContentLesson, Paragraph et ajout des namespaces sans la portée via les crochets
continuous-integration/drone/push Build is passing Details

pull/31/head
Clement CHIEU 1 year ago
parent 8576c5515b
commit a1876b108c

@ -30,7 +30,6 @@ namespace DbContextLib
protected override void OnModelCreating(ModelBuilder modelBuilder) protected override void OnModelCreating(ModelBuilder modelBuilder)
{ {
modelBuilder.Entity<ContentLessonEntity>().HasKey(c => c.LessonId); modelBuilder.Entity<ContentLessonEntity>().HasKey(c => c.LessonId);
modelBuilder.Entity<ContentLessonEntity>().HasKey(c => c.LessonPartId);
modelBuilder.Entity<SuccessEntity>().HasKey(s => s.UserId); modelBuilder.Entity<SuccessEntity>().HasKey(s => s.UserId);
modelBuilder.Entity<SuccessEntity>().HasKey(s => s.InquiryId); modelBuilder.Entity<SuccessEntity>().HasKey(s => s.InquiryId);
modelBuilder.Entity<InquiryEntity>().HasKey(s => s.Id); modelBuilder.Entity<InquiryEntity>().HasKey(s => s.Id);

@ -1,7 +1,7 @@
namespace Dto namespace Dto;
public class BlackListDTO
{ {
public class BlackListDTO
{
public string Email { get; set; } public string Email { get; set; }
public DateOnly ExpirationDate { get; set; } public DateOnly ExpirationDate { get; set; }
@ -10,5 +10,4 @@
Email = email; Email = email;
ExpirationDate = expirationDate; ExpirationDate = expirationDate;
} }
}
} }

@ -1,14 +1,17 @@
namespace Dto namespace Dto;
public abstract class ContentLessonDTO
{ {
public class ContentLessonDTO public int Id { get; set; }
{ public string ContentContent { get; set; }
public string ContentTitle { get; set; }
public int LessonId { get; set; } public int LessonId { get; set; }
public int LessonPartId { get; set; }
public ContentLessonDTO(int lessonId, int lessonPartId) protected ContentLessonDTO(int id, string contentContent, string contentTitle, int lessonId)
{ {
Id = id;
ContentContent = contentContent;
ContentTitle = contentTitle;
LessonId = lessonId; LessonId = lessonId;
LessonPartId = lessonPartId;
}
} }
} }

@ -1,7 +1,7 @@
namespace Dto namespace Dto;
public class InquiryDTO
{ {
public class InquiryDTO
{
public int Id { get;} public int Id { get;}
public string Title { get; set; } public string Title { get; set; }
@ -22,5 +22,4 @@
Database = database; Database = database;
InquiryTable = inquiryTable; InquiryTable = inquiryTable;
} }
}
} }

@ -1,7 +1,7 @@
namespace Dto namespace Dto;
public class InquiryTableDTO
{ {
public class InquiryTableDTO
{
public int OwnerId { get; set; } public int OwnerId { get; set; }
public string DatabaseName { get; set; } public string DatabaseName { get; set; }
@ -15,5 +15,4 @@
DatabaseName = databaseName; DatabaseName = databaseName;
ConnectionInfo = connectionInfo; ConnectionInfo = connectionInfo;
} }
}
} }

@ -1,11 +1,12 @@
namespace Dto namespace Dto;
public class LessonDTO
{ {
public class LessonDTO
{
public int Id { get; } public int Id { get; }
public string? Title { get; set; } public string? Title { get; set; }
public string? LastPublisher { get; set; } public string? LastPublisher { get; set; }
public DateOnly? LastEdit { get; set; } public DateOnly? LastEdit { get; set; }
public ICollection<ContentLessonDTO> Content { get; set; } = new List<ContentLessonDTO>();
public LessonDTO() { } public LessonDTO() { }
public LessonDTO(int id, string title, string lastPublisher, DateOnly? lastEdit) public LessonDTO(int id, string title, string lastPublisher, DateOnly? lastEdit)
@ -22,5 +23,4 @@
LastPublisher = lastPublisher; LastPublisher = lastPublisher;
LastEdit = lastEdit; LastEdit = lastEdit;
} }
}
} }

@ -1,7 +1,7 @@
namespace Dto namespace Dto;
public class NotepadDTO
{ {
public class NotepadDTO
{
public int Id { get; set; } public int Id { get; set; }
public int UserId { get; set; } public int UserId { get; set; }
public int InquiryId { get; set; } public int InquiryId { get; set; }
@ -22,5 +22,4 @@
InquiryId = inquiryId; InquiryId = inquiryId;
Notes = notes; Notes = notes;
} }
}
} }

@ -1,32 +1,17 @@
namespace Dto namespace Dto;
public class ParagraphDTO : ContentLessonDTO
{ {
public class ParagraphDTO
{
public int Id { get; }
public string Title { get; set; }
public string Content { get; set; }
public string Info { get; set; } public string Info { get; set; }
public string Query { get; set; } public string Query { get; set; }
public string Comment { get; set; } public string Comment { get; set; }
public ParagraphDTO() { } public ParagraphDTO(int id, string title, string content, string info, string query, string comment, int lessonId) :
base(id, content,
public ParagraphDTO(int id, string title, string content, string info, string query, string comment) title, lessonId)
{ {
Id = id;
Title = title;
Content = content;
Info = info; Info = info;
Query = query; Query = query;
Comment = comment; Comment = comment;
} }
public ParagraphDTO(string title, string content, string info, string query, string comment)
{
Title = title;
Content = content;
Info = info;
Query = query;
Comment = comment;
}
}
} }

@ -1,7 +1,7 @@
namespace Dto namespace Dto;
public class SolutionDTO
{ {
public class SolutionDTO
{
public int OwnerId { get; set; } public int OwnerId { get; set; }
public string MurdererFirstName { get; set; } public string MurdererFirstName { get; set; }
public string MurdererLastName { get; set; } public string MurdererLastName { get; set; }
@ -26,5 +26,4 @@
MurderWeapon = murderWeapon; MurderWeapon = murderWeapon;
Explanation = explanation; Explanation = explanation;
} }
}
} }

@ -1,7 +1,7 @@
namespace Dto namespace Dto;
public class SuccessDTO
{ {
public class SuccessDTO
{
public int UserId { get; set; } public int UserId { get; set; }
public int InquiryId { get; set; } public int InquiryId { get; set; }
public bool IsFinished { get; set; } public bool IsFinished { get; set; }
@ -14,5 +14,4 @@
InquiryId = inquiryId; InquiryId = inquiryId;
IsFinished = isFinished; IsFinished = isFinished;
} }
}
} }

@ -1,7 +1,7 @@
namespace Dto namespace Dto;
public class UserDTO
{ {
public class UserDTO
{
public int Id { get; set; } public int Id { get; set; }
public string Username { get; set; } public string Username { get; set; }
public string Password { get; set; } public string Password { get; set; }
@ -30,5 +30,4 @@
{ {
return $"{Id}\t{Username}\t{Email}\t{IsAdmin}"; return $"{Id}\t{Username}\t{Email}\t{IsAdmin}";
} }
}
} }

@ -3,22 +3,37 @@
namespace Entities; namespace Entities;
[Table("ContentLesson")] [Table("ContentLesson")]
public class ContentLessonEntity public abstract class ContentLessonEntity
{ {
[ForeignKey(nameof(Lesson))] public int Id { get; set; }
public int LessonId { get; set; } public string ContentContent { get; set; }
public LessonEntity Lesson { get; set; } public string ContentTitle { get; set; }
[ForeignKey(nameof(Lesson))] public int LessonId { get; set; }
public LessonEntity Lesson { get; set; } = null!;
[ForeignKey(nameof(Paragraph))] protected ContentLessonEntity()
public int LessonPartId { get; set; } {
public ParagraphEntity Paragraph { get; set; } }
public ContentLessonEntity(){} protected ContentLessonEntity(int id, string contentContent, string contentTitle)
public ContentLessonEntity(int lessonId, LessonEntity lesson, int lessonPartId, ParagraphEntity paragraph)
{ {
Id = id;
ContentContent = contentContent;
ContentTitle = contentTitle;
}
protected ContentLessonEntity(int id, int lessonId, string contentContent, string contentTitle)
{
Id = id;
LessonId = lessonId; LessonId = lessonId;
Lesson = lesson; ContentContent = contentContent;
LessonPartId = lessonPartId; ContentTitle = contentTitle;
Paragraph = paragraph; }
protected ContentLessonEntity(string contentContent, string contentTitle)
{
ContentContent = contentContent;
ContentTitle = contentTitle;
} }
} }

@ -9,13 +9,8 @@ public class LessonEntity
public string? Title { get; set; } public string? Title { get; set; }
public string? LastPublisher { get; set; } public string? LastPublisher { get; set; }
public DateOnly? LastEdit { get; set; } public DateOnly? LastEdit { get; set; }
public ICollection<ContentLessonEntity> Content { get; set; } = new List<ContentLessonEntity>();
public LessonEntity() { }
public LessonEntity(int id)
{
Id = id;
}
public LessonEntity(int id, string title, string lastPublisher, DateOnly? lastEdit) public LessonEntity(int id, string title, string lastPublisher, DateOnly? lastEdit)
{ {
Id = id; Id = id;

@ -3,36 +3,31 @@
namespace Entities; namespace Entities;
[Table("Paragraph")] [Table("Paragraph")]
public class ParagraphEntity public class ParagraphEntity : ContentLessonEntity
{ {
public int Id { get; set; } // ID
public string Title { get; set; } // ContentContent
public string Content { get; set; } // ContentTitle
// LessonId
public string Info { get; set; } public string Info { get; set; }
public string Query { get; set; } public string Query { get; set; }
public string Comment { get; set; } public string Comment { get; set; }
public ParagraphEntity() { } public ParagraphEntity()
public ParagraphEntity(int id)
{ {
Id = id;
} }
public ParagraphEntity(int id, string title, string content, string info, string query, string comment) public ParagraphEntity(int id, string title, string content, string info, string query,
string comment, int idLesson) : base(id, idLesson, content, title)
{ {
Id = id;
Title = title;
Content = content;
Info = info; Info = info;
Query = query; Query = query;
Comment = comment; Comment = comment;
} }
public ParagraphEntity(string title, string content, string info, string query, string comment)
public ParagraphEntity(string title, string content, string info, string query, string comment) : base(content,
title)
{ {
Title = title;
Content = content;
Info = info; Info = info;
Query = query; Query = query;
Comment = comment; Comment = comment;

@ -1,7 +1,7 @@
namespace ModelToEntities.Business namespace Model;
public class BlackList
{ {
public class BlackList
{
public string Email { get; set; } public string Email { get; set; }
public DateOnly ExpirationDate { get; set; } public DateOnly ExpirationDate { get; set; }
@ -10,5 +10,4 @@
Email = email; Email = email;
ExpirationDate = expirationDate; ExpirationDate = expirationDate;
} }
}
} }

@ -1,14 +1,24 @@
namespace ModelToEntities.Business namespace Model;
public abstract class ContentLesson
{ {
public class ContentLesson public int Id { get; set; }
{ public string ContentContent { get; set; }
public ContentLesson(int lessonId, int lessonPartId) public string ContentTitle { get; set; }
public int LessonId { get; set; }
protected ContentLesson(string contentContent, string contentTitle)
{ {
LessonId = lessonId; ContentContent = contentContent;
LessonPartId = lessonPartId; ContentTitle = contentTitle;
} }
public int LessonId { get; set; } protected ContentLesson(int id, string contentContent, string contentTitle, int lessonId)
public int LessonPartId { get; set; } {
Id = id;
ContentContent = contentContent;
ContentTitle = contentTitle;
LessonId = lessonId;
} }
} }

@ -1,7 +1,7 @@
namespace ModelToEntities.Business namespace Model;
public class Inquiry
{ {
public class Inquiry
{
public int Id { get; set; } public int Id { get; set; }
public string Title { get; set; } public string Title { get; set; }
public string Description { get; set; } public string Description { get; set; }
@ -20,5 +20,4 @@
Database = database; Database = database;
InquiryTable = inquiryTable; InquiryTable = inquiryTable;
} }
}
} }

@ -1,7 +1,7 @@
namespace ModelToEntities.Business namespace Model;
public class InquiryTable
{ {
public class InquiryTable
{
public int OwnerId { get; set; } public int OwnerId { get; set; }
public string DatabaseName { get; set; } public string DatabaseName { get; set; }
public string ConnectionInfo { get; set; } public string ConnectionInfo { get; set; }
@ -14,5 +14,4 @@
ConnectionInfo = connectionInfo; ConnectionInfo = connectionInfo;
} }
}
} }

@ -1,18 +1,13 @@
namespace ModelToEntities.Business namespace Model;
public class Lesson
{ {
public class Lesson
{
public int Id { get; } public int Id { get; }
public string? Title { get; set; } public string? Title { get; set; }
public string? LastPublisher { get; set; } public string? LastPublisher { get; set; }
public DateOnly? LastEdit { get; set; } public DateOnly? LastEdit { get; set; }
public ICollection<ContentLesson> Content { get; set; } = new List<ContentLesson>();
public Lesson() { }
public Lesson(int id)
{
Id = id;
}
public Lesson(int id, string title, string lastPublisher, DateOnly? lastEdit) public Lesson(int id, string title, string lastPublisher, DateOnly? lastEdit)
{ {
Id = id; Id = id;
@ -27,5 +22,4 @@
LastPublisher = lastPublisher; LastPublisher = lastPublisher;
LastEdit = lastEdit; LastEdit = lastEdit;
} }
}
} }

@ -1,7 +1,7 @@
namespace ModelToEntities.Business namespace Model;
public class Notepad
{ {
public class Notepad
{
public int Id { get; set; } public int Id { get; set; }
public int UserId { get; set; } public int UserId { get; set; }
public int InquiryId { get; set; } public int InquiryId { get; set; }
@ -22,5 +22,4 @@
InquiryId = inquiryId; InquiryId = inquiryId;
Notes = notes; Notes = notes;
} }
}
} }

@ -1,37 +1,24 @@
namespace ModelToEntities.Business namespace Model;
{
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 Paragraph() { } public class Paragraph : ContentLesson
{
public Paragraph(int id) public string Info { get; set; }
{ public string Query { get; set; }
Id = id; public string Comment { get; set; }
}
public Paragraph(int id, string title, string content, string info, string query, string comment) public Paragraph(string title, string content, string info, string query, string comment) : base(content,
title)
{ {
Id = id;
Title = title;
Content = content;
Info = info; Info = info;
Query = query; Query = query;
Comment = comment; Comment = comment;
} }
public Paragraph(string title, string content, string info, string query, string comment)
public Paragraph(int id, string title, string content, string info, string query, string comment, int lessonId) :
base(id, content, title, lessonId)
{ {
Title = title;
Content = content;
Info = info; Info = info;
Query = query; Query = query;
Comment = comment; Comment = comment;
} }
}
} }

@ -1,7 +1,7 @@
namespace ModelToEntities.Business namespace Model;
public class Solution
{ {
public class Solution
{
public int OwnerId { get; set; } public int OwnerId { get; set; }
public string MurdererFirstName { get; set; } public string MurdererFirstName { get; set; }
public string MurdererLastName { get; set; } public string MurdererLastName { get; set; }
@ -26,5 +26,4 @@
MurderWeapon = murderWeapon; MurderWeapon = murderWeapon;
Explanation = explanation; Explanation = explanation;
} }
}
} }

@ -1,7 +1,7 @@
namespace ModelToEntities.Business namespace Model;
public class Success
{ {
public class Success
{
public int UserId { get; set; } public int UserId { get; set; }
public int InquiryId { get; set; } public int InquiryId { get; set; }
public bool IsFinished { get; set; } public bool IsFinished { get; set; }
@ -14,5 +14,4 @@
InquiryId = inquiryId; InquiryId = inquiryId;
IsFinished = isFinished; IsFinished = isFinished;
} }
}
} }

@ -1,7 +1,7 @@
namespace ModelToEntities.Business namespace Model;
public class User
{ {
public class User
{
public int Id { get; set; } public int Id { get; set; }
public string Username { get; set; } public string Username { get; set; }
public string Password { get; set; } public string Password { get; set; }
@ -17,5 +17,4 @@
Email = email; Email = email;
IsAdmin = isAdmin; IsAdmin = isAdmin;
} }
}
} }

@ -1,6 +1,6 @@
using Dto; using Dto;
using Entities; using Entities;
using ModelToEntities.Business; using Model;
namespace Shared.Mapper; namespace Shared.Mapper;

@ -1,34 +0,0 @@
using Dto;
using Entities;
using ModelToEntities.Business;
namespace Shared.Mapper;
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));
}
}

@ -1,6 +1,6 @@
using Dto; using Dto;
using Entities; using Entities;
using ModelToEntities.Business; using Model;
namespace Shared.Mapper; namespace Shared.Mapper;

@ -1,6 +1,6 @@
using Dto; using Dto;
using Entities; using Entities;
using ModelToEntities.Business; using Model;
namespace Shared.Mapper; namespace Shared.Mapper;

@ -1,6 +1,6 @@
using Dto; using Dto;
using Entities; using Entities;
using ModelToEntities.Business; using Model;
namespace Shared.Mapper; namespace Shared.Mapper;

@ -1,6 +1,6 @@
using Dto; using Dto;
using Entities; using Entities;
using ModelToEntities.Business; using Model;
namespace Shared.Mapper; namespace Shared.Mapper;

@ -1,6 +1,6 @@
using Dto; using Dto;
using Entities; using Entities;
using ModelToEntities.Business; using Model;
namespace Shared.Mapper; namespace Shared.Mapper;
@ -8,31 +8,35 @@ public static class ParagraphMapper
{ {
public static Paragraph FromDTOToModel(ParagraphDTO dto) public static Paragraph FromDTOToModel(ParagraphDTO dto)
{ {
return new Paragraph(dto.Id, dto.Title, dto.Content, dto.Info, dto.Query, dto.Comment); return new Paragraph(dto.ContentTitle, dto.ContentContent, dto.Info, dto.Query, dto.Comment);
} }
public static Paragraph FromEntityToModel(ParagraphEntity model) public static Paragraph FromEntityToModel(ParagraphEntity model)
{ {
return new Paragraph(model.Id, model.Title, model.Content, model.Info, model.Query, model.Comment); return new Paragraph(model.ContentTitle, model.ContentContent, model.Info, model.Query, model.Comment);
} }
public static ParagraphDTO FromEntityToDTO(ParagraphEntity model) public static ParagraphDTO FromEntityToDTO(ParagraphEntity model)
{ {
return new ParagraphDTO(model.Id, model.Title, model.Content, model.Info, model.Query, model.Comment); return new ParagraphDTO(model.Id, model.ContentTitle, model.ContentContent, model.Info, model.Query,
model.Comment, model.LessonId);
} }
public static ParagraphDTO FromModelToDTO(Paragraph model) public static ParagraphDTO FromModelToDTO(Paragraph model)
{ {
return new ParagraphDTO(model.Id, model.Title, model.Content, model.Info, model.Query, model.Comment); return new ParagraphDTO(model.Id, model.ContentTitle, model.ContentContent, model.Info, model.Query,
model.Comment, model.LessonId);
} }
public static ParagraphEntity FromDTOToEntity(ParagraphDTO dto) public static ParagraphEntity FromDTOToEntity(ParagraphDTO dto)
{ {
return new ParagraphEntity(dto.Id, dto.Title, dto.Content, dto.Info, dto.Query, dto.Comment); return new ParagraphEntity(dto.Id, dto.ContentTitle, dto.ContentContent, dto.Info, dto.Query, dto.Comment,
dto.LessonId);
} }
public static Paragraph FromModelToEntity(Paragraph model) public static ParagraphEntity FromModelToEntity(Paragraph model)
{ {
return new Paragraph(model.Id, model.Title, model.Content, model.Info, model.Query, model.Comment); return new ParagraphEntity(model.Id, model.ContentTitle, model.ContentContent, model.Info, model.Query,
model.Comment, model.LessonId);
} }
} }

@ -1,6 +1,6 @@
using Dto; using Dto;
using Entities; using Entities;
using ModelToEntities.Business; using Model;
namespace Shared.Mapper; namespace Shared.Mapper;

@ -1,6 +1,6 @@
using Dto; using Dto;
using Entities; using Entities;
using ModelToEntities.Business; using Model;
namespace Shared.Mapper; namespace Shared.Mapper;

@ -1,6 +1,6 @@
using Dto; using Dto;
using Entities; using Entities;
using ModelToEntities.Business; using Model;
namespace Shared.Mapper; namespace Shared.Mapper;

Loading…
Cancel
Save