prueba tecnica

This commit is contained in:
Alejandro
2025-06-15 18:29:25 +02:00
parent 9758ee0bc6
commit d97e55a83f
127 changed files with 6488 additions and 1 deletions

View File

@@ -0,0 +1,7 @@
namespace ProximaContracts.Domain.Contracts.DTOs.Request
{
public class ContractByIdRequestDto
{
public int Id { get; set; }
}
}

View File

@@ -0,0 +1,20 @@
using System.ComponentModel.DataAnnotations;
namespace ProximaContracts.Domain.Contracts.DTOs.Request
{
public class CreateContractRequestDto
{
[Required]
[MaxLength(20)]
public string ContractorIdNumber { get; set; } = null!;
[Required]
[MaxLength(50)]
public string ContractorName { get; set; } = null!;
[Required]
[MaxLength(100)]
public string ContractorSurname { get; set; } = null!;
[Required]
[Range(1, int.MaxValue, ErrorMessage = "RateId must be greater than 0.")]
public int RateId { get; set; }
}
}

View File

@@ -0,0 +1,16 @@
using System.ComponentModel.DataAnnotations;
namespace ProximaContracts.Domain.Contracts.DTOs.Request
{
public class UpdateContractRequestDto
{
[Required]
public int ContractId { get; set; }
[Required]
public int RateId { get; set; }
public string? ContractorIdNumber { get; set; }
public string? ContractorName { get; set; }
public string? ContractorSurname { get; set; }
public DateTime? ContractInitDate { get; set; }
}
}

View File

@@ -0,0 +1,14 @@
namespace ProximaContracts.Domain.Contracts.DTOs.Response
{
public class ContractByIdResponseDto
{
public int Id { get; set; }
public string ContractorIdNumber { get; set; }
public string ContractorName { get; set; }
public string ContractorSurname { get; set; }
public DateTime ContractInitDate { get; set; }
public int RateId { get; set; }
public string RateName { get; set; }
public decimal RatePrice { get; set; }
}
}

View File

@@ -0,0 +1,9 @@
namespace ProximaContracts.Domain.Contracts.DTOs.Response
{
public class CreateContractResponseDto
{
public bool IsCreated { get; set; }
public int NewContractId { get; set; }
public string Message { get; set; }
}
}

View File

@@ -0,0 +1,11 @@
namespace ProximaContracts.Domain.Contracts.DTOs.Response
{
public class GetContractsResponseDto
{
public int Id { get; set; }
public string ContractorName { get; set; }
public string ContractorSurname { get; set; }
public DateTime ContractInitDate { get; set; }
public string RateName { get; set; }
}
}

View File

@@ -0,0 +1,9 @@
namespace ProximaContracts.Domain.Contracts.DTOs.Response
{
public class UpdateContractResponseDto
{
public bool IsUpdated { get; set; }
public int ContractId { get; set; }
public string Message { get; set; }
}
}

View File

@@ -0,0 +1,14 @@
namespace ProximaContracts.Domain.Contracts.Entities
{
public class ContractByIdEntity
{
public int Id { get; set; }
public string ContractorIdNumber { get; set; }
public string ContractorName { get; set; }
public string ContractorSurname { get; set; }
public DateTime ContractInitDate { get; set; }
public int RateId { get; set; }
public string RateName { get; set; }
public decimal RatePrice { get; set; }
}
}

View File

@@ -0,0 +1,11 @@
namespace ProximaContracts.Domain.Contracts.Entities
{
public class GetContractsEntity
{
public int Id { get; set; }
public string ContractorName { get; set; }
public string ContractorSurname { get; set; }
public DateTime ContractInitDate { get; set; }
public string RateName { get; set; }
}
}

View File

@@ -0,0 +1,40 @@
using AutoMapper;
using Npgsql;
using ProximaContracts.Domain.Contracts.DTOs.Response;
using ProximaContracts.Domain.Contracts.Entities;
namespace ProximaContracts.Domain.Contracts.Mappings
{
public class ContractProfile : Profile
{
public ContractProfile()
{
#region Contract By ID
CreateMap<NpgsqlDataReader, ContractByIdEntity>()
.ForMember(d => d.Id, o => o.MapFrom(s => s.GetInt32(s.GetOrdinal("Id"))))
.ForMember(d => d.ContractorIdNumber, o => o.MapFrom(s => s.GetString(s.GetOrdinal("ContractorIdNumber"))))
.ForMember(d => d.ContractorName, o => o.MapFrom(s => s.GetString(s.GetOrdinal("ContractorName"))))
.ForMember(d => d.ContractorSurname, o => o.MapFrom(s => s.GetString(s.GetOrdinal("ContractorSurname"))))
.ForMember(d => d.ContractInitDate, o => o.MapFrom(s => s.GetDateTime(s.GetOrdinal("ContractInitDate"))))
.ForMember(d => d.RateId, o => o.MapFrom(s => s.GetInt32(s.GetOrdinal("RateId"))))
.ForMember(d => d.RateName, o => o.MapFrom(s => s.GetString(s.GetOrdinal("RateName"))))
.ForMember(d => d.RatePrice, o => o.MapFrom(s => s.GetFieldValue<decimal>(s.GetOrdinal("RatePrice"))))
;
CreateMap<ContractByIdEntity, ContractByIdResponseDto>();
#endregion ContractByID
#region Contracts All
CreateMap<NpgsqlDataReader, GetContractsEntity>()
.ForMember(d => d.Id, o => o.MapFrom(s => s.GetInt32(s.GetOrdinal("Id"))))
.ForMember(d => d.ContractorName, o => o.MapFrom(s => s.GetString(s.GetOrdinal("ContractorName"))))
.ForMember(d => d.ContractorSurname, o => o.MapFrom(s => s.GetString(s.GetOrdinal("ContractorSurname"))))
.ForMember(d => d.ContractInitDate, o => o.MapFrom(s => s.GetDateTime(s.GetOrdinal("ContractInitDate"))))
.ForMember(d => d.RateName, o => o.MapFrom(s => s.GetString(s.GetOrdinal("RateName"))))
;
CreateMap<GetContractsEntity, GetContractsResponseDto>();
#endregion Contracts All
}
}
}