falta interfaz venta
This commit is contained in:
@@ -14,7 +14,7 @@ public class RepositorioContratos: RepositorioBase<RepositorioContratos> {
|
||||
}
|
||||
}
|
||||
|
||||
public bool CargaPrecontrato(Contrato? c = null, Notificacione? n = null) {
|
||||
public bool CargaPrecontrato( Contrato? c = null, Notificacione? n = null) {
|
||||
if (c == null || c.Habilitado == 1) return false;
|
||||
if (n == null) return false;
|
||||
var con = Context;
|
||||
@@ -201,4 +201,39 @@ public class RepositorioContratos: RepositorioBase<RepositorioContratos> {
|
||||
var con = Context;
|
||||
return con.Contratos.Where(x=>x.Fechainicio.Year == year).Any();
|
||||
}
|
||||
|
||||
public bool SetOpcionVenta(Venta v, long idcontrato) {
|
||||
var con = Context;
|
||||
var cont = con.Contratos.Include(x=>x.IdventaNavigation).FirstOrDefault(x=>x.Id == idcontrato);
|
||||
if (cont != null) return false;
|
||||
|
||||
v.Id = (con.Ventas.Any()?con.Ventas.Count():0)+1;
|
||||
|
||||
cont.IdventaNavigation = v;
|
||||
con.Ventas.Add(v);
|
||||
return Guardar(con);
|
||||
}
|
||||
|
||||
public bool CargaPrecontratoOpcionVenta(Contrato c, Notificacione n, Venta v) {
|
||||
if (c == null || c.Habilitado == 1) return false;
|
||||
if (n == null) return false;
|
||||
var con = Context;
|
||||
|
||||
var prop = con.Propiedades.FirstOrDefault(x=>x.Id==c.Idpropiedad);
|
||||
if (prop == null) return false;
|
||||
prop.Idestado = 2;
|
||||
|
||||
c.Iddivisa = prop.Iddivisa;
|
||||
c.Id = (con.Contratos.Any() ? con.Contratos.Max(x => x.Id) : 0) + 1;
|
||||
c.Monto = prop.Monto;
|
||||
|
||||
v.Id = (con.Ventas.Any()?con.Ventas.Count():0)+1;
|
||||
c.Idventa = v.Id;
|
||||
|
||||
con.Ventas.Add(v);
|
||||
con.Contratos.Add(c);
|
||||
con.Notificaciones.Add(n);
|
||||
|
||||
return Guardar(con);
|
||||
}
|
||||
}
|
||||
|
||||
26
Modelo/RepositorioVentas.cs
Normal file
26
Modelo/RepositorioVentas.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using Entidades;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Modelo;
|
||||
public class RepositorioVentas: RepositorioBase<RepositorioVentas> {
|
||||
public Contrato? ObtenerVentaPorContrato(long idcontrato) {
|
||||
var con = Context;
|
||||
var c = con.Contratos.Include(x=>x.Idcanons).Include(x=>x.IdventaNavigation).ThenInclude(x=>x.IddivisaNavigation)
|
||||
.FirstOrDefault(x=>x.Id == idcontrato);
|
||||
if (c == null || c.IdventaNavigation == null) return null;
|
||||
return c;
|
||||
}
|
||||
|
||||
public bool PatchVenta(Venta venta) {
|
||||
var con = Context;
|
||||
var a = con.Ventas.FirstOrDefault(x=>x.Id == venta.Id);
|
||||
|
||||
a.IdVendedor = venta.IdVendedor;
|
||||
a.IdComprador = venta.IdComprador;
|
||||
a.Idpropiedad = venta.Idpropiedad;
|
||||
a.Fechainicio = venta.Fechainicio;
|
||||
a.Idestado=2;
|
||||
|
||||
return Guardar(con);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user