From 942b14631ddefa6c88e26e926702aeb057405456 Mon Sep 17 00:00:00 2001 From: masapountz Date: Mon, 19 Feb 2024 11:06:02 +0100 Subject: [PATCH] Fin mapper Inquiry --- API_SQLuedo/Model/DTO/InquiryDTO.cs | 4 +-- API_SQLuedo/Model/Mappers/InquiryMapper.cs | 25 +++++++++++++++++++ .../Model/Mappers/InquiryTableMapper.cs | 23 ++++++++++++++++- API_SQLuedo/Model/Mappers/SolutionMapper.cs | 25 +++++++++++++++++++ 4 files changed, 74 insertions(+), 3 deletions(-) diff --git a/API_SQLuedo/Model/DTO/InquiryDTO.cs b/API_SQLuedo/Model/DTO/InquiryDTO.cs index 27e3841..4fac705 100644 --- a/API_SQLuedo/Model/DTO/InquiryDTO.cs +++ b/API_SQLuedo/Model/DTO/InquiryDTO.cs @@ -18,9 +18,9 @@ namespace Model.DTO public bool IsUser { get; set; } public InquiryTableDTO Database { get; set; } - public SolutionEntityDTO InquiryTable { get; set; } + public SolutionDTO InquiryTable { get; set; } - public InquiryDTO(int id, string title, string description, bool isUser, InquiryTableDTO database, SolutionEntityDTO inquiryTable) + public InquiryDTO(int id, string title, string description, bool isUser, InquiryTableDTO database, SolutionDTO inquiryTable) { Id = id; Title = title; diff --git a/API_SQLuedo/Model/Mappers/InquiryMapper.cs b/API_SQLuedo/Model/Mappers/InquiryMapper.cs index cb43278..65df083 100644 --- a/API_SQLuedo/Model/Mappers/InquiryMapper.cs +++ b/API_SQLuedo/Model/Mappers/InquiryMapper.cs @@ -16,5 +16,30 @@ namespace Model.Mappers return new Inquiry(InqDto.Id,InqDto.Title,InqDto.Description,InqDto.IsUser,InqDto.Database.FromDTOToModel(),InqDto.InquiryTable.FromDTOToModel()); } + public static Inquiry FromEntityToModel(this InquiryEntity InqEntity) + { + return new Inquiry(InqEntity.Id, InqEntity.Title, InqEntity.Description, InqEntity.IsUser, InqEntity.Database.FromEntityToModel(), InqEntity.InquiryTable.FromEntityToModel()); + } + + + public static InquiryEntity FromModelToEntity(this Inquiry Inq) + { + return new InquiryEntity(Inq.Id, Inq.Title, Inq.Description, Inq.IsUser, Inq.Database.FromModelToEntity(), Inq.InquiryTable.FromModelToEntity()); + } + + public static InquiryEntity FromDTOToEntity(this InquiryDTO InqDto) + { + return new InquiryEntity(InqDto.Id, InqDto.Title, InqDto.Description, InqDto.IsUser, InqDto.Database.FromDTOToEntity(), InqDto.InquiryTable.FromDTOToEntity()); + } + public static InquiryDTO FromModelToDTO(this Inquiry Inq) + { + return new InquiryDTO(Inq.Id, Inq.Title, Inq.Description, Inq.IsUser, Inq.Database.FromModelToDTO(), Inq.InquiryTable.FromModelToDTO()); + } + + public static InquiryDTO FromEntityToDTO(this InquiryEntity InqEntity) + { + return new InquiryDTO(InqEntity.Id, InqEntity.Title, InqEntity.Description, InqEntity.IsUser, InqEntity.Database.FromEntityToDTO(), InqEntity.InquiryTable.FromEntityToDTO()); + + } } } diff --git a/API_SQLuedo/Model/Mappers/InquiryTableMapper.cs b/API_SQLuedo/Model/Mappers/InquiryTableMapper.cs index 71e62d6..6262326 100644 --- a/API_SQLuedo/Model/Mappers/InquiryTableMapper.cs +++ b/API_SQLuedo/Model/Mappers/InquiryTableMapper.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Entities.SQLudeoDB; namespace Model.Mappers { @@ -15,9 +16,29 @@ namespace Model.Mappers return new InquiryTable(InqTDto.OwnerId, InqTDto.ConnectionInfo, InqTDto.DatabaseName); } + public static InquiryTable FromEntityToModel(this InquiryTableEntity InqTEntity) + { + return new InquiryTable(InqTEntity.OwnerId, InqTEntity.ConnectionInfo, InqTEntity.DatabaseName); + } + public static InquiryTableDTO FromModelToDTO(this InquiryTable InqT) { - return new InquiryTableDTO(InqT.OwnerId, InqT.Owner, InqT.DatabaseName, InqT.ConnectionInfo); + return new InquiryTableDTO(InqT.OwnerId, InqT.Owner.FromModelToDTO(), InqT.DatabaseName, InqT.ConnectionInfo); + } + + public static InquiryTableDTO FromEntityToDTO(this InquiryTableEntity InqTEntity) + { + return new InquiryTableDTO(InqTEntity.OwnerId, InqTEntity.Owner.FromEntityToDTO(), InqTEntity.DatabaseName, InqTEntity.ConnectionInfo); + } + + public static InquiryTableEntity FromModelToEntity(this InquiryTable InqT) + { + return new InquiryTableEntity(InqT.OwnerId, InqT.DatabaseName, InqT.ConnectionInfo); + } + + public static InquiryTableEntity FromDTOToEntity(this InquiryTableDTO dto) + { + return new InquiryTableEntity(dto.OwnerId, dto.DatabaseName, dto.ConnectionInfo); } } } diff --git a/API_SQLuedo/Model/Mappers/SolutionMapper.cs b/API_SQLuedo/Model/Mappers/SolutionMapper.cs index 0041921..affbeef 100644 --- a/API_SQLuedo/Model/Mappers/SolutionMapper.cs +++ b/API_SQLuedo/Model/Mappers/SolutionMapper.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Entities.SQLudeoDB; using Model.Business; using Model.DTO; @@ -14,5 +15,29 @@ namespace Model.Mappers { return new Solution(dto.OwnerId,dto.Owner.FromDTOToModel(),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); + } + 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); + } + + 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); + } + + 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); + } + + 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); + } } }