Вы можете исправить обе свои функции согласно приведенному ниже объяснению.
Если ваша первая функция:
[HttpGet("{id}")]
public Visitor Get(string id)
{
var result = _visitorRepository.GetFromDB(id);
if (result != _visitorRepository.GetFromDB(id))
return StatusCode(200); // Somehow make this to return "Visitor" type
if (result != null)
return result; // Somehow make this to return "Visitor" type
else
return StatusCode(408); // Somehow make this to return "Visitor" type
}
Если вы хотите перейти ко второй функции, внесите следующие изменения:
[HttpGet("{id}")]
public ActionResult Get(string id)
{
var result = _visitorRepository.GetFromDB(id);
if (result != _visitorRepository.GetFromDB(id))
return Ok();
if (result != null)
return Ok(result); // Return type of ActionResult
else
return BadRequest();
}
Только для справки ActionResult
для StatusCode(200)
тип возврата может быть как
return Ok();