Click here to Skip to main content
15,899,754 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everybody!!!

How do I Make a Master details like this; Person has income and credit history using WebAPI, part of my web api code in c# is....

C#
public class PersonasController : ApiController
{
    CreditosConexion context = new CreditosConexion();

    //get all customer
    [HttpGet]
    public IEnumerable<Persona> Get()
    {
        return context.PersonaSet.AsEnumerable();
    }
}



when I get the structure of Api / GET-api-People this is the result:

C#
Collection of Persona
     Name	Description	Type	Additional information
    PersonaID	integer	 None.
    TipoDocumento	string	None.
    NumeroIdentificacion	string	None.
    PrimerNombre	string	None.
    SegundoNombre	string	None.
    PrimerApellido	string	None.
    SegundoApellido	string	None.
    FechaNacimiento	date	None.
    PersonasaCargo	integer	None.
    Genero	string	None.
    Credito	Collection of Credito	None.
    IngresosPersona	Collection of IngresosPersona	None.


and the Response Formats

application/json, text/json
[
  {
    "PersonaID": 1,
    "TipoDocumento": "sample string 2",
    "NumeroIdentificacion": "sample string 3",
    "PrimerNombre": "sample string 4",
    "SegundoNombre": "sample string 5",
    "PrimerApellido": "sample string 6",
    "SegundoApellido": "sample string 7",
    "FechaNacimiento": "2016-07-27T10:43:34.8845012-05:00",
    "PersonasaCargo": 1,
    "Genero": "sample string 8",
    "Credito": [
      {
        "CreditoID": 1,
        "PersonaID": 1,
        "NumeroCuotas": 1,
        "EstadoCredito": 1,
        "MontoAprovado": 1.0,
        "Plazo": 1,
        "Tasa": 1.0,
        "FechaCredito": "2016-07-27T10:43:34.8850014-05:00"
      },
      {
        "CreditoID": 1,
        "PersonaID": 1,
        "NumeroCuotas": 1,
        "EstadoCredito": 1,
        "MontoAprovado": 1.0,
        "Plazo": 1,
        "Tasa": 1.0,
        "FechaCredito": "2016-07-27T10:43:34.8850014-05:00"
      }
    ],
    "IngresosPersona": [
      {
        "IngresosPersonaId": 1,
        "PersonaID": 1,
        "SalarioBasico": 1.0,
        "IngresosExtrasLaborables": 1.0,
        "OtrosIngresosExtasNoLaborables": 1.0
      },
      {
        "IngresosPersonaId": 1,
        "PersonaID": 1,
        "SalarioBasico": 1.0,
        "IngresosExtrasLaborables": 1.0,
        "OtrosIngresosExtasNoLaborables": 1.0
      }
    ]
  },
  {
    "PersonaID": 1,
    "TipoDocumento": "sample string 2",
    "NumeroIdentificacion": "sample string 3",
    "PrimerNombre": "sample string 4",
    "SegundoNombre": "sample string 5",
    "PrimerApellido": "sample string 6",
    "SegundoApellido": "sample string 7",
    "FechaNacimiento": "2016-07-27T10:43:34.8845012-05:00",
    "PersonasaCargo": 1,
    "Genero": "sample string 8",
    "Credito": [
      {
        "CreditoID": 1,
        "PersonaID": 1,
        "NumeroCuotas": 1,
        "EstadoCredito": 1,
        "MontoAprovado": 1.0,
        "Plazo": 1,
        "Tasa": 1.0,
        "FechaCredito": "2016-07-27T10:43:34.8850014-05:00"
      },
      {
        "CreditoID": 1,
        "PersonaID": 1,
        "NumeroCuotas": 1,
        "EstadoCredito": 1,
        "MontoAprovado": 1.0,
        "Plazo": 1,
        "Tasa": 1.0,
        "FechaCredito": "2016-07-27T10:43:34.8850014-05:00"
      }
    ],
    "IngresosPersona": [
      {
        "IngresosPersonaId": 1,
        "PersonaID": 1,
        "SalarioBasico": 1.0,
        "IngresosExtrasLaborables": 1.0,
        "OtrosIngresosExtasNoLaborables": 1.0
      },
      {
        "IngresosPersonaId": 1,
        "PersonaID": 1,
        "SalarioBasico": 1.0,
        "IngresosExtrasLaborables": 1.0,
        "OtrosIngresosExtasNoLaborables": 1.0
      }
    ]
  }
]



Angular cannot be used?, can I do it with just MVC?
If I'll use Angular how to make this?

What I have tried:

C#
public class PersonasController : ApiController
{
    CreditosConexion context = new CreditosConexion();

    //get all customer
    [HttpGet]
    public IEnumerable<Persona> Get()
    {
        return context.PersonaSet.AsEnumerable();
    }
}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900