Primera subida

This commit is contained in:
Alejandro Sarmiento
2024-04-06 03:32:16 +02:00
parent c97b4a8179
commit b672887299
44 changed files with 44426 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
using AutoMapper;
using back.Entities.DTOs.Request;
using back.Entities;
using back.Infra;
using back.Application.Contracts.Persistence;
namespace back.Application.Services
{
public class CasaService : GenericService<Casa, CasaRequestDto, CasaUpdateRequestDto>
{
private readonly IMapper _mapper;
private readonly DireccionService dService;
private readonly IAsyncRepository<Casa> repo;
public CasaService(IMapper mapper, IAsyncRepository<Casa> _repo, DireccionService dService) : base(mapper, _repo)
{
_mapper = mapper;
this.dService = dService;
repo = _repo;
}
public async override Task<Casa> Add(CasaRequestDto dto)
{
var direccion = _mapper.Map<Direccion>(dto.Direction);
var d = await dService.AddOne(direccion);
var casa = _mapper.Map<Casa>(dto);
casa.Direccion = d;
return await repo.AddAsync(casa);
}
}
}