Simplify IActionResult return value logic It would be nice to simplify the verbosity of this:

public IActionResult Get(int id)
{
    var movie = context.GetMovie(id);

    if (movie != null)
    {
        return Ok(movie);
    }
    else
    {
        return NotFound();
    }
}


with something like this:

public IActionResult Get(int id)
{
    var movie = context.GetMovie(id);
    return (movie != null) ? Ok(movie) : NotFound();
}


Of course, this is an error because the two objects in the ternary must be of the same type, not just sharing the same inheritance (or is this incorrect?).

The closest I can get is to explicitly cast one of the values as an IActionResult:

return (movie != null) ? Ok(movie) : (IActionResult) NotFound();


Is there a better option?
So, as mentioned in comments: the code is readable and there are no issues with "verbosity". And as mentioned you can get rid of else statement, also it's a good habit to exclude "bad" cases at first.

public IActionResult Get(int id)
{
    var movie = context.GetMovie(id);

    if (movie == null)
    {
        return NotFound();
    }

    return Ok(movie);
}