using System; using System.Linq; using bdAsegasa.dbcontext; using tsUtilidades; using tsEFCore8; namespace bdAsegasa.db { public partial class polizasagrario { public entidades Tomador { get { return this.idTomadorNavigation; } } public entidades Asegurado { get { return this.idAseguradoNavigation; } } public direcciones DireccionAsegurado { get { return this.idDomicilioAseguradoNavigation; } } public string CodNomAgente { get { return this.idAgenteNavigation.Codigo + "-" + this.idAgenteNavigation.Nombre; } } public string Fraccio { get { string Retorno = "NO"; if (this.fraccionada == true) Retorno = "SI"; return Retorno; } } public int? idSubAgente_Especial { get { if (this.idSubagente.HasValue && this.idAgenteNavigation.Codigo == "000047002186") { using (var bd = tscgestionasegasa.NuevoContexto()) { var Codigo = this.idSubagenteNavigation.Codigo.Substring(0, 2) + "00"; var subage = bd.subagentes.FirstOrDefault(x => x.idAgente == this.idAgente && x.Codigo == Codigo); if (subage != null) { return subage.idSubagente; } else { return null; } } } return this.idSubagente; } } public string ProvinciaAsegurado { get { if (this.idAseguradoNavigation != null && this.idAseguradoNavigation.idDireccionPrincipalNavigation != null && this.idAseguradoNavigation.idDireccionPrincipalNavigation.CodigoPostal != null && this.idAseguradoNavigation.idDireccionPrincipalNavigation.CodigoPostal.Length > 2) { return this.idAseguradoNavigation.idDireccionPrincipalNavigation.CodigoPostal.Substring(0, 2); } else { return ""; } } } public ListadoGenericoPA AListadoGenericoPA() { return new ListadoGenericoPA(this); } } public class ListadoGenericoPA { public ListadoGenericoPA(polizasagrario p) { NumeroPóliza = p.poliza; if (p.fechaPoliza.HasValue) { FechaPóliza = new DateTime(p.fechaPoliza.Value.Year, p.fechaPoliza.Value.Month, p.fechaPoliza.Value.Day); } Línea = p.idPlanLineaNavigation?.descripcion; Compañía = p.idCiaNavigation?.Nombre; CIFAsegurado = p.Asegurado?.CIF; Asegurado = p.Asegurado?.RazonSocial; if (!string.IsNullOrEmpty(p.telefono1Asegurado)) { Teléfono1 = p.telefono1Asegurado; } else { if (p.idAseguradoNavigation != null) { Teléfono1 = p.idAseguradoNavigation.Telefono1; } else { Teléfono1 = ""; } } if (!string.IsNullOrEmpty(p.telefono2Asegurado)) { Teléfono2 = p.telefono2Asegurado; } else { if (p.idAseguradoNavigation != null) { Teléfono2 = p.idAseguradoNavigation.Telefono2; } else { Teléfono2 = ""; } } if (!string.IsNullOrEmpty(p.emailAsegurado)) { Email = p.emailAsegurado; } else { if (p.idAseguradoNavigation != null) { Email = p.idAseguradoNavigation.Email; } else { Email = ""; } } } public string NumeroPóliza { get; set; } public DateTime? FechaPóliza { get; set; } public string Compañía { get; set; } public string Línea { get; set; } public string CIFAsegurado { get; set; } public string Asegurado { get; set; } public string Teléfono1 { get; set; } public string Teléfono2 { get; set; } public string Email { get; set; } } }