Esempio n. 1
0
 private async Task ConfigMappersGeneral(MapperConfig mConfig)
 {
     //Comunidad
     mConfig
     .AddConstructor <Comunidad>(x => new Comunidad(x.Id, x.CIF, x.Baja, x.Nombre, x.Codigo, this.ACData, true))
     .AddMemberCreator <Comunidad>("_CuentaBancaria1", x => new CuentaBancaria(x.CuentaBancaria))
     .AddMemberCreator <Comunidad>("_CuentaBancaria2", x => new CuentaBancaria(x.CuentaBancaria2))
     .AddMemberCreator <Comunidad>("_CuentaBancaria3", x => new CuentaBancaria(x.CuentaBancaria3))
     .AddNestedProperty <Comunidad, DireccionPostal>(false, x => x.Direccion)
     .AddNestedProperty <Comunidad, Persona>(false, x => x.Presidente, x => x.Secretario, x => x.Tesorero)
     .AddNestedProperty <Comunidad, HashSet <int> >(false, x => x.Vocales)
     .AddNestedProperty <Comunidad, Ejercicio>(false, x => x.EjercicioActivo)
     .EndConfig <Comunidad>();
     mConfig
     .AddConstructor <ComunidadDLO>(x => new ComunidadDLO(x.Id, x.Codigo, x.CIF, x.Baja, x.Nombre, x.TipoVia + x.Direccion,
                                                          x.CuentaBancaria, x.CuentaBancaria2, x.CuentaBancaria3, x.NombrePresidente, x.NombreSecretario, x.NombreTesorero, x.FechaPunteo,
                                                          x.UltimaFechaBanco))
     .MapOnlyConstructor <ComunidadDLO>()
     .EndConfig <ComunidadDLO>();
     //Ejercicio
     mConfig.EndConfig <Ejercicio>();
     mConfig
     .AddConstructor <EjercicioDLO>(x => new EjercicioDLO(x.Id, x.FechaComienzo, x.FechaFinal, x.IdOwnerComunidad, x.Cerrado))
     .MapOnlyConstructor <EjercicioDLO>()
     .EndConfig <EjercicioDLO>();
     mConfig
     .AddConstructor <EjercicioDLOParaSideTool>(x => new EjercicioDLOParaSideTool(x.Id, x.FechaComienzo, x.FechaFinal, x.Cerrado))
     .MapOnlyConstructor <EjercicioDLOParaSideTool>()
     .EndConfig <EjercicioDLOParaSideTool>();
     //Persona
     mConfig
     .AddConstructor <Persona>(x => new Persona(x.Id, x.NIF, x.Nombre, true))
     .AddMemberCreator <Persona>("_CuentaBancaria", x => new CuentaBancaria(x.CuentaBancaria))
     .AddNestedProperty <Persona, DireccionPostal>(false, x => x.Direccion)
     .AddMemberCreator <Persona, sTelefono>(x => x.Telefono1, x => new sTelefono(x.Telefono, x.Tipo))
     .AddMemberCreator <Persona, sTelefono>(x => x.Telefono2, x => new sTelefono(x.Telefono2, x.Tipo2))
     .AddMemberCreator <Persona, sTelefono>(x => x.Telefono3, x => new sTelefono(x.Telefono3, x.Tipo3))
     .EndConfig <Persona>();
     //GrupoCuentas
     mConfig
     .AddConstructor <GrupoCuentas>(x => new GrupoCuentas(x.Id, x.IdOwnerComunidadNullable, x.Grupo))
     .EndConfig <GrupoCuentas>();
     //iGrupoGastos
     mConfig
     .AddInterfaceToObjectCondition <iGrupoGastos>(x => !(bool)x.Aceptado, typeof(GrupoGastos))
     .AddInterfaceToObjectCondition <iGrupoGastos>(x => (bool)x.Aceptado, typeof(GrupoGastosAceptado))
     .EndConfig <iGrupoGastos>();
     //GrupoGastos
     mConfig
     .AddDictionary <GrupoGastos>("_FincasCoeficientes", new string[] { "FincasCoeficientes", "Coeficiente" })
     .AddNestedProperty <GrupoGastos, List <Cuota> >(false, x => x.Cuotas)
     .AddNestedProperty <GrupoGastos>(false, "_Cuentas")
     .EndConfig <GrupoGastos>();
     mConfig
     .AddConstructor <GrupoGastosDLO>(x => new GrupoGastosDLO(x.Id, x.IdOwnerComunidad, x.IdPresupuesto, x.Nombre,
                                                              x.CoeficientesCustom, x.Importe))
     .MapOnlyConstructor <GrupoGastosDLO>()
     .EndConfig <GrupoGastosDLO>();
     //GrupoGastosAceptado y structs
     mConfig.EndConfig <GrupoGastosAceptado.sDatosFincaGGAceptado>();
     mConfig.EndConfig <GrupoGastosAceptado.sDatosCuotaGGAceptado>();
     mConfig.EndConfig <GrupoGastosAceptado.sDatosCuentaGGAceptado>();
     mConfig
     .AddNestedProperty <GrupoGastosAceptado>(false, "_Fincas")
     .AddNestedProperty <GrupoGastosAceptado>(false, "_Cuotas")
     .AddNestedProperty <GrupoGastosAceptado>(false, "_Cuentas")
     .EndConfig <GrupoGastosAceptado>();
     //CuentaParaPresupuesto
     mConfig
     .AddNestedProperty <GrupoGastos.CuentaParaPresupuesto, CuentaMayor>(false, x => x.Cuenta)
     .EndConfig <GrupoGastos.CuentaParaPresupuesto>();
     //Presupuesto
     mConfig
     .AddConstructor <Presupuesto>(x =>
                                   new Presupuesto(x.Id, x.IdOwnerComunidad, x.IdOwnerEjercicio, x.Codigo, this.ACData, x.Aceptado, (TipoRepartoPresupuesto)x.TipoReparto))
     .AddNestedProperty <Presupuesto>(true, "_GruposDeGasto")
     .EndConfig <Presupuesto>();
     mConfig
     .AddConstructor <PresupuestoDLO>(x => new PresupuestoDLO(x.Id, x.IdOwnerComunidad, x.Titulo, x.Total, x.Aceptado,
                                                              (TipoRepartoPresupuesto)x.TipoReparto, x.Codigo))
     .MapOnlyConstructor <PresupuestoDLO>()
     .EndConfig <PresupuestoDLO>();
 }