SES-128 Add ErrorResponse
This commit is contained in:
parent
99da683632
commit
20d81f4bf5
@ -23,9 +23,16 @@ namespace SessionCompanion.Controllers
|
||||
/// </summary>
|
||||
/// <returns>Lista wszystkich broni w bazie danych</returns>
|
||||
[HttpGet("getAllWeapons")]
|
||||
public async Task<List<WeaponViewModel>> GetWeapons()
|
||||
public async Task<Either<List<WeaponViewModel>, ErrorResponse>> GetWeapons()
|
||||
{
|
||||
return _service.Get().ToList();
|
||||
var weapons = _service.Get().ToList();
|
||||
if (!weapons.Any())
|
||||
return new ErrorResponse()
|
||||
{
|
||||
StatusCode = 204,
|
||||
Message = "No weapons in database"
|
||||
};
|
||||
return weapons;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user