SES-128 Endpoint Broni #52
@ -25,14 +25,19 @@ namespace SessionCompanion.Controllers
|
|||||||
[HttpGet("getAllWeapons")]
|
[HttpGet("getAllWeapons")]
|
||||||
public async Task<Either<List<WeaponViewModel>, ErrorResponse>> GetWeapons()
|
public async Task<Either<List<WeaponViewModel>, ErrorResponse>> GetWeapons()
|
||||||
|
|||||||
{
|
{
|
||||||
var weapons = _service.Get().ToList();
|
try
|
||||||
if (!weapons.Any())
|
{
|
||||||
|
var weapons = _service.Get().ToList();
|
||||||
|
return weapons;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
return new ErrorResponse()
|
return new ErrorResponse()
|
||||||
{
|
{
|
||||||
StatusCode = 204,
|
StatusCode = 204,
|
||||||
Message = "No weapons in database"
|
Message = e.Message
|
||||||
};
|
};
|
||||||
return weapons;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user
Brak Error Response