Primera subida
This commit is contained in:
31
back/Application/Services/CasaService.cs
Normal file
31
back/Application/Services/CasaService.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user