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)
{
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.InquiryId);
modelBuilder.Entity<InquiryEntity>().HasKey(s => s.Id);

@ -1,5 +1,5 @@
namespace Dto
{
namespace Dto;
public class BlackListDTO
{
public string Email { get; set; }
@ -11,4 +11,3 @@
ExpirationDate = expirationDate;
}
}
}

@ -1,14 +1,17 @@
namespace Dto
{
public class ContentLessonDTO
namespace Dto;
public abstract class ContentLessonDTO
{
public int Id { get; set; }
public string ContentContent { get; set; }
public string ContentTitle { 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;
LessonPartId = lessonPartId;
}
}
}

@ -1,5 +1,5 @@
namespace Dto
{
namespace Dto;
public class InquiryDTO
{
public int Id { get;}
@ -23,4 +23,3 @@
InquiryTable = inquiryTable;
}
}
}

@ -1,5 +1,5 @@
namespace Dto
{
namespace Dto;
public class InquiryTableDTO
{
@ -16,4 +16,3 @@
ConnectionInfo = connectionInfo;
}
}
}

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

@ -1,5 +1,5 @@
namespace Dto
{
namespace Dto;
public class NotepadDTO
{
public int Id { get; set; }
@ -23,4 +23,3 @@
Notes = notes;
}
}
}

@ -1,32 +1,17 @@
namespace Dto
{
public class ParagraphDTO
namespace Dto;
public class ParagraphDTO : ContentLessonDTO
{
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 ParagraphDTO() { }
public ParagraphDTO(int id, string title, string content, string info, string query, string comment)
public ParagraphDTO(int id, string title, string content, string info, string query, string comment, int lessonId) :
base(id, content,
title, lessonId)
{
Id = id;
Title = title;
Content = content;
Info = info;
Query = query;
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,5 +1,5 @@
namespace Dto
{
namespace Dto;
public class SolutionDTO
{
public int OwnerId { get; set; }
@ -27,4 +27,3 @@
Explanation = explanation;
}
}
}

@ -1,5 +1,5 @@
namespace Dto
{
namespace Dto;
public class SuccessDTO
{
public int UserId { get; set; }
@ -15,4 +15,3 @@
IsFinished = isFinished;
}
}
}

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

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

@ -9,13 +9,8 @@ public class LessonEntity
public string? Title { get; set; }
public string? LastPublisher { 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)
{
Id = id;

@ -3,36 +3,31 @@
namespace Entities;
[Table("Paragraph")]
public class ParagraphEntity
public class ParagraphEntity : ContentLessonEntity
{
public int Id { get; set; }
public string Title { get; set; }
public string Content { get; set; }
// ID
// ContentContent
// ContentTitle
// LessonId
public string Info { get; set; }
public string Query { get; set; }
public string Comment { get; set; }
public ParagraphEntity() { }
public ParagraphEntity(int id)
public ParagraphEntity()
{
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;
Query = query;
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;
Query = query;
Comment = comment;

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

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

@ -1,5 +1,5 @@
namespace ModelToEntities.Business
{
namespace Model;
public class Inquiry
{
public int Id { get; set; }
@ -21,4 +21,3 @@
InquiryTable = inquiryTable;
}
}
}

@ -1,5 +1,5 @@
namespace ModelToEntities.Business
{
namespace Model;
public class InquiryTable
{
public int OwnerId { get; set; }
@ -15,4 +15,3 @@
}
}
}

@ -1,18 +1,13 @@
namespace ModelToEntities.Business
{
namespace Model;
public class Lesson
{
public int Id { get; }
public string? Title { get; set; }
public string? LastPublisher { 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)
{
Id = id;
@ -28,4 +23,3 @@
LastEdit = lastEdit;
}
}
}

@ -1,5 +1,5 @@
namespace ModelToEntities.Business
{
namespace Model;
public class Notepad
{
public int Id { get; set; }
@ -23,4 +23,3 @@
Notes = notes;
}
}
}

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

@ -1,5 +1,5 @@
namespace ModelToEntities.Business
{
namespace Model;
public class Solution
{
public int OwnerId { get; set; }
@ -27,4 +27,3 @@
Explanation = explanation;
}
}
}

@ -1,5 +1,5 @@
namespace ModelToEntities.Business
{
namespace Model;
public class Success
{
public int UserId { get; set; }
@ -15,4 +15,3 @@
IsFinished = isFinished;
}
}
}

@ -1,5 +1,5 @@
namespace ModelToEntities.Business
{
namespace Model;
public class User
{
public int Id { get; set; }
@ -18,4 +18,3 @@
IsAdmin = isAdmin;
}
}
}

@ -1,6 +1,6 @@
using Dto;
using Entities;
using ModelToEntities.Business;
using Model;
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 Entities;
using ModelToEntities.Business;
using Model;
namespace Shared.Mapper;

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

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

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

@ -1,6 +1,6 @@
using Dto;
using Entities;
using ModelToEntities.Business;
using Model;
namespace Shared.Mapper;
@ -8,31 +8,35 @@ 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);
return new Paragraph(dto.ContentTitle, dto.ContentContent, 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);
return new Paragraph(model.ContentTitle, model.ContentContent, 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);
return new ParagraphDTO(model.Id, model.ContentTitle, model.ContentContent, model.Info, model.Query,
model.Comment, model.LessonId);
}
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)
{
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 Entities;
using ModelToEntities.Business;
using Model;
namespace Shared.Mapper;

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

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

Loading…
Cancel
Save