diff --git a/Jellyfin.Api/Controllers/DisplayPreferencesController.cs b/Jellyfin.Api/Controllers/DisplayPreferencesController.cs index 0554091b45..e15e9c4be6 100644 --- a/Jellyfin.Api/Controllers/DisplayPreferencesController.cs +++ b/Jellyfin.Api/Controllers/DisplayPreferencesController.cs @@ -1,6 +1,5 @@ #nullable enable -using System; using System.ComponentModel.DataAnnotations; using System.Threading; using MediaBrowser.Controller.Net; @@ -45,20 +44,13 @@ namespace Jellyfin.Api.Controllers [FromQuery] [Required] string userId, [FromQuery] [Required] string client) { - try + var result = _displayPreferencesRepository.GetDisplayPreferences(displayPreferencesId, userId, client); + if (result == null) { - var result = _displayPreferencesRepository.GetDisplayPreferences(displayPreferencesId, userId, client); - if (result == null) - { - return NotFound(); - } - - return Ok(result); - } - catch (Exception e) - { - return StatusCode(StatusCodes.Status500InternalServerError, e.Message); + return NotFound(); } + + return Ok(result); } /// @@ -80,30 +72,23 @@ namespace Jellyfin.Api.Controllers [FromQuery, BindRequired] string client, [FromBody, BindRequired] DisplayPreferences displayPreferences) { - try + if (!ModelState.IsValid) { - if (!ModelState.IsValid) - { - return BadRequest(ModelState); - } - - if (displayPreferencesId == null) - { - // do nothing. - } - - _displayPreferencesRepository.SaveDisplayPreferences( - displayPreferences, - userId, - client, - CancellationToken.None); - - return Ok(); + return BadRequest(ModelState); } - catch (Exception e) + + if (displayPreferencesId == null) { - return StatusCode(StatusCodes.Status500InternalServerError, e.Message); + // do nothing. } + + _displayPreferencesRepository.SaveDisplayPreferences( + displayPreferences, + userId, + client, + CancellationToken.None); + + return Ok(); } } }