Ajout de 3 Mapper (Inquiry,InquiryTable,Solution) + Ajout classes métier correspondantes + DTO (Peut-être revoir les informations à garder)

pull/26/head
Maxime SAPOUNTZIS 1 year ago
parent 8b4c11e842
commit 76791a0e27

@ -8,7 +8,7 @@ namespace Entities.SQLudeoDB
{
public class InquiryEntity
{
public int Id { get; set; }
public int Id { get; }
public string Title { get; set; }
public string Description { get; set; }
public bool IsUser { get; set; }
@ -25,5 +25,15 @@ namespace Entities.SQLudeoDB
Database = database;
InquiryTable = inquiryTable;
}
public InquiryEntity(string title, string description, bool isUser, InquiryTableEntity database, SolutionEntity inquiryTable)
{
Id = 0;
Title = title;
Description = description;
IsUser = isUser;
Database = database;
InquiryTable = inquiryTable;
}
}
}

@ -9,22 +9,22 @@ namespace Entities.SQLudeoDB
public class LessonEntity
{
public int Id { get; set; }
public string Titla { get; set; }
public string Title { get; set; }
public string LastPublisher { get; set; }
public DateOnly LastEdit { get; set; }
public LessonEntity() { }
public LessonEntity(int id, string titla, string lastPublisher, DateOnly lastEdit)
public LessonEntity(int id, string title, string lastPublisher, DateOnly lastEdit)
{
Id = id;
Titla = titla;
Title = title;
LastPublisher = lastPublisher;
LastEdit = lastEdit;
}
public LessonEntity(string titla, string lastPublisher, DateOnly lastEdit)
public LessonEntity(string title, string lastPublisher, DateOnly lastEdit)
{
Titla = titla;
Title = title;
LastPublisher = lastPublisher;
LastEdit = lastEdit;
}

@ -1,5 +1,7 @@
using System;
using Entities.SQLudeoDB;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -8,5 +10,23 @@ namespace Model.Business
{
public class Inquiry
{
public int Id { get; set; }
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 Inquiry() { }
public Inquiry(int id, string title, string description, bool isUser, InquiryTable database, Solution inquiryTable)
{
Id = id;
Title = title;
Description = description;
IsUser = isUser;
Database = database;
InquiryTable = inquiryTable;
}
}
}

@ -0,0 +1,32 @@
using Entities.SQLudeoDB;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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; }
public InquiryTable() { }
public InquiryTable(int inquiryId, string databaseName, string connectionInfo)
{
OwnerId = inquiryId;
DatabaseName = databaseName;
ConnectionInfo = connectionInfo;
}
public InquiryTable(Inquiry owner, string databaseName, string connectionInfo)
{
Owner = owner;
DatabaseName = databaseName;
ConnectionInfo = connectionInfo;
}
}
}

@ -0,0 +1,40 @@
using Entities.SQLudeoDB;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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)
{
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)
{
Owner = owner;
MurdererFirstName = murdererFirstName;
MurdererLastName = murdererLastName;
MurderPlace = murderPlace;
MurderWeapon = murderWeapon;
Explanation = explanation;
}
}
}

@ -1,4 +1,5 @@
using System;
using Entities.SQLudeoDB;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -8,5 +9,25 @@ namespace Model.DTO
{
public class InquiryDTO
{
public int Id { get;}
public string Title { get; set; }
public string Description { get; set; }
public bool IsUser { get; set; }
public InquiryTableDTO Database { get; set; }
public SolutionEntityDTO InquiryTable { get; set; }
public InquiryDTO(int id, string title, string description, bool isUser, InquiryTableDTO database, SolutionEntityDTO inquiryTable)
{
Id = id;
Title = title;
Description = description;
IsUser = isUser;
Database = database;
InquiryTable = inquiryTable;
}
}
}

@ -0,0 +1,29 @@
using Model.Business;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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)
{
OwnerId = ownerId;
Owner = owner;
DatabaseName = databaseName;
ConnectionInfo = connectionInfo;
}
}
}

@ -0,0 +1,40 @@
using Model.Business;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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)
{
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)
{
Owner = owner;
MurdererFirstName = murdererFirstName;
MurdererLastName = murdererLastName;
MurderPlace = murderPlace;
MurderWeapon = murderWeapon;
Explanation = explanation;
}
}
}

@ -1,17 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices.ObjectiveC;
using System.Text;
using System.Threading.Tasks;
namespace Model.Mappers
{
public interface IMapper
{
public Object FromEntityToModel(object o);
public Object FromModelToDTO(object o);
public Object FromDTOToModel(object o);
public Object FromModelToEntity(object o);
}
}

@ -3,29 +3,18 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Entities.SQLudeoDB;
using Model.Business;
using Model.DTO;
namespace Model.Mappers
{
public class InquiryMapper
public static class InquiryMapper
{
public object FromDTOToModel()
public static Inquiry FromDTOToModel(this InquiryDTO InqDto)
{
throw new NotImplementedException();
return new Inquiry(InqDto.Id,InqDto.Title,InqDto.Description,InqDto.IsUser,InqDto.Database.FromDTOToModel(),InqDto.InquiryTable.FromDTOToModel());
}
public object FromEntityToModel()
{
throw new NotImplementedException();
}
public object FromModelToDTO()
{
throw new NotImplementedException();
}
public object FromModelToEntity()
{
throw new NotImplementedException();
}
}
}

@ -0,0 +1,23 @@
using Model.Business;
using Model.DTO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Model.Mappers
{
public static class InquiryTableMapper
{
public static InquiryTable FromDTOToModel(this InquiryTableDTO InqTDto)
{
return new InquiryTable(InqTDto.OwnerId, InqTDto.ConnectionInfo, InqTDto.DatabaseName);
}
public static InquiryTableDTO FromModelToDTO(this InquiryTable InqT)
{
return new InquiryTableDTO(InqT.OwnerId, InqT.Owner, InqT.DatabaseName, InqT.ConnectionInfo);
}
}
}

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model.Business;
using Model.DTO;
namespace Model.Mappers
{
public static class SolutionMapper
{
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);
}
}
}

@ -10,11 +10,19 @@ namespace Model.Mappers
{
return new User(dto.Id, dto.Username, dto.Password, dto.Email, dto.IsAdmin);
}
public static UserEntity FromDTOToEntity(this UserDTO dto)
{
return new UserEntity(dto.Id, dto.Username, dto.Password, dto.Email, dto.IsAdmin);
}
public static User FromEntityToModel(this UserEntity entity)
{
return new User(entity.Id, entity.Username, entity.Password, entity.Email, entity.IsAdmin);
}
public static UserDTO FromEntityToDTO(this UserEntity entity)
{
return new UserDTO(entity.Id, entity.Username, entity.Password, entity.Email, entity.IsAdmin);
}
public static UserDTO FromModelToDTO(this User user)
{
@ -25,5 +33,6 @@ namespace Model.Mappers
{
return new UserEntity(user.Id, user.Username, user.Password, user.Email, user.IsAdmin);
}
}
}

Loading…
Cancel
Save