fix iba a dar una excepcion por desearilazion lo que estaba antes ahi
This commit is contained in:
33
Aspnet/Builder/DtoBuilder/DefectoDtoBuilder.cs
Normal file
33
Aspnet/Builder/DtoBuilder/DefectoDtoBuilder.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Entidades.Dto;
|
||||
|
||||
namespace AlquilaFacil.Builder;
|
||||
public class DefectoDtoBuilder: Builder<DefectoDto> {
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -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<DefectoDto> 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
|
||||
|
||||
@@ -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;} ="";
|
||||
}
|
||||
Reference in New Issue
Block a user