Não sei se minha pergunta expressa bem, mas o tipo de retorno que preciso é algo como isso:
(
{
"Id": 0,
"Name": "string",
"Image": "string",
"Why": "string",
"What": "string",
"WhatWillWeDo": "string",
"ProjStatus": 0,
"Course": {
"CourseId": 0,
"Name": "string"
},
"CourseId": 0
}
)
Porém, em meu retorno obtenho apenas:
(
{
"id": 0,
"name": "string",
"image": "string",
"why": "string",
"what": "string",
"whatWillWeDo": "string",
"projStatus": 0,
"course": null,
"courseId": 0
}
)
Método GET no Controller
public ActionResult<IEnumerable<Project>> Get()
{
try
{
var projects = (from project in _acess.GetProjects()
select project).ToList();
return projects;
}
catch (Exception ex)
{
return null;
}
}
Classe que é chamada no controller
public IEnumerable<Project> GetProjects()
{
// var aux = context.Projects.ToList().Count;
return context.Project.ToList();
}
A classe de projetos
public class Project
{
(Key)
public int Id { get; set; }
(Required(ErrorMessage = "Nome é obrigatório"))
public string Name { get; set; }
public string Image { get; set; }
public string Why { get; set; }
public string What { get; set; }
public string WhatWillWeDo { get; set; }
public ProjectStatus ProjStatus { get; set; }
public Course Course { get; set; }
public int CourseId { get; set; }
public enum ProjectStatus
{
development = 0,
publicated = 1
}
}