Exit method after async call, or not

When a trivial exit condition occurs in the intermediate method GetUserCourseStatusAsync and a Task<T> is expected, a dummy Task<T> should be returned instead of null. The following code can be used to return a dummy Task<T>:

// Trivial return of dummy task ("User not registered")
return Task.FromResult<IGetUserCourseResponse>(null);

It is important to note that returning null when a trivial exit condition occurs may be an anti-pattern and should be reconsidered.

To return a dummy Task<T> instead of null when a trivial exit condition occurs in the intermediate method GetUserCourseStatusAsync, the code below can be used:

// Trivial return of dummy task ("User not registered")
return Task.FromResult<IGetUserCourseResponse>(null);

It is important to note that returning null when a trivial exit condition occurs may be an anti-pattern and should be reconsidered.