falta testear
This commit is contained in:
@@ -81,8 +81,9 @@ public class RepositorioContratos: RepositorioBase<RepositorioContratos> {
|
||||
x.Habilitado == 0 &&
|
||||
x.Cancelado == 0);
|
||||
|
||||
if (contr == null) return false;
|
||||
if (contr == null || contr.IdpropiedadNavigation == null) return false;
|
||||
contr.Cancelado = 1;
|
||||
contr.IdpropiedadNavigation.Idestado = 1;
|
||||
return Guardar(con);
|
||||
}
|
||||
|
||||
@@ -105,4 +106,40 @@ public class RepositorioContratos: RepositorioBase<RepositorioContratos> {
|
||||
contrato.UrlContrato = nuevoNombreArchivo;
|
||||
return Guardar(con);
|
||||
}
|
||||
|
||||
public bool AceptarContrato(long idcontrato) {
|
||||
var con = Context;
|
||||
Contrato? cont = con.Contratos
|
||||
.Include(x=>x.Idcanons)
|
||||
.Include(x=>x.Idpropiedad)
|
||||
.FirstOrDefault(x=>x.Id ==idcontrato &&
|
||||
x.Habilitado ==0 &&
|
||||
x.Cancelado == 0);
|
||||
|
||||
if (cont == null || cont.IdpropiedadNavigation==null) return false;
|
||||
|
||||
cont.Habilitado = 1;
|
||||
var fecha = cont.Fechainicio;
|
||||
|
||||
for (int i = 0; i < cont.MesesHastaAumento; i++) {
|
||||
Canon can = new Canon{
|
||||
Fecha = fecha.AddMonths(i),
|
||||
Monto = cont.IdpropiedadNavigation.Monto,
|
||||
Pagado = 0
|
||||
};
|
||||
can.Id = (con.Canons.Any()? con.Canons.Max(x=>x.Id) :0)+1;
|
||||
|
||||
cont.Idcanons.Add(can);
|
||||
}
|
||||
return Guardar(con);
|
||||
}
|
||||
|
||||
public bool CancelarPrecontrato(long idcontrato) {
|
||||
var con = Context;
|
||||
Contrato? cont = con.Contratos.Include(x=>x.Idpropiedad).FirstOrDefault(x=>x.Id ==idcontrato && x.Habilitado ==0);
|
||||
if (cont == null|| cont.IdpropiedadNavigation==null) return false;
|
||||
cont.Cancelado = 1;
|
||||
cont.IdpropiedadNavigation.Idestado = 1;
|
||||
return Guardar(con);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user