diff --git a/Aspnet/Builder/DtoBuilder/DefectoDtoBuilder.cs b/Aspnet/Builder/DtoBuilder/DefectoDtoBuilder.cs new file mode 100644 index 0000000..e480e2f --- /dev/null +++ b/Aspnet/Builder/DtoBuilder/DefectoDtoBuilder.cs @@ -0,0 +1,33 @@ +using Entidades.Dto; + +namespace AlquilaFacil.Builder; +public class DefectoDtoBuilder: Builder { + public DefectoDtoBuilder SetId(long id) { + data.Id = id; + return this; + } + public DefectoDtoBuilder SetDesc(string Descripcion){ + data.Descripcion = Descripcion; + return this; + } + public DefectoDtoBuilder SetCosto(Decimal Costo){ + data.Costo = Costo; + return this; + } + public DefectoDtoBuilder SetEstado(string estado){ + data.Estado = estado; + return this; + } + public DefectoDtoBuilder SetIdContrato(long id){ + data.IdContrato = id; + data.Id = id; + } + public DefectoDtoBuilder SetPagaInquilino(ulong pag){ + data.Pagainquilino=pag==1?"Si":"no"; + return this; + } + public DefectoDtoBuilder SetDivisa(string divisa){ + data.Divisa = divisa; + return this; + } +} \ No newline at end of file diff --git a/Aspnet/Controllers/DefectoController.cs b/Aspnet/Controllers/DefectoController.cs index 9d635f5..f2e1c46 100644 --- a/Aspnet/Controllers/DefectoController.cs +++ b/Aspnet/Controllers/DefectoController.cs @@ -1,3 +1,4 @@ +using AlquilaFacil.Builder; using Entidades; using Entidades.Dto; using Microsoft.AspNetCore.Mvc; @@ -30,8 +31,20 @@ public class DefectoController: ControllerBase { if (cont.Dniinquilino != cli.Dni && cont.Dnipropietario != cli.Dni) return BadRequest(new { message = "no deberias tener acceso a esto"}); var l = RepositorioDefectos.Singleton.ObtenerDefectosPorIdContrato(Idcontrato); - return Ok(l); - + List ll = new(); + foreach (var i in l){ + var n = new DefectoDtoBuilder() + .SetId(i.Id) + .SetDesc(i.Descripcion) + .SetCosto(i.Costo) + .SetEstado(i.IdestadoNavigation.Descipcion) + .SetIdContrato(i.Idcontrato??0) + .SetPagaInquilino(i.Pagainquilino) + .SetDivisa(i.IddivisaNavigation.Signo) + .Build(); + ll.Add(n); + } + return Ok(ll); } [HttpPost("api/defecto")] // WIP tengo que hablar con mi madre diff --git a/Entidades/Dto/DefectoDto.cs b/Entidades/Dto/DefectoDto.cs index 81d6eb7..d28ea26 100644 --- a/Entidades/Dto/DefectoDto.cs +++ b/Entidades/Dto/DefectoDto.cs @@ -3,8 +3,8 @@ public class DefectoDto { public long Id { get; set;} public string Descripcion { get; set;} =""; public Decimal Costo { get; set;} - public int Idestado { get; set;} + public string Estado { get; set;} =""; public long Idcontrato { get; set;} - public bool Pagainquilino { get; set;} - public int Iddivisa { get; set;} + public string Pagainquilino { get; set;} =""; + public string Divisa { get; set;} =""; } \ No newline at end of file