0
I have the code below, and I need the ID returned as soon as I insert the object. If there is already a registered project, it does not do the insertion, but I need to return some data as empty or null, but I cannot define the same variable to save a null value and a value from project because they have different types, so what should I do in this case?
public ActionResult<Project> Post(Project project)
{
var get = _acess.GetProject(project.Id);
try
{
if (get == null)
{
_acess.AddProject(project);
}
else
{
get = null;
}
return Ok();
}
catch (DataException ex)
{
return BadRequest(ex.Message);
}
}
I got it, thank you very much!
– Tester