diff --git a/src/DigitalData.UserManager.API/Controllers/GroupOfUserController.cs b/src/DigitalData.UserManager.API/Controllers/GroupOfUserController.cs index 488472c..1036c69 100644 --- a/src/DigitalData.UserManager.API/Controllers/GroupOfUserController.cs +++ b/src/DigitalData.UserManager.API/Controllers/GroupOfUserController.cs @@ -14,68 +14,44 @@ public class GroupOfUserController : BaseAuthController logger, IGroupOfUserService service, IUserService userService) : base(logger, service, userService) { } - + [HttpDelete] public async Task Delete([FromQuery] int groupId, [FromQuery] int userId) { - try + return await _service.DeleteAsyncByGroupUserId(groupId, userId).ThenAsync(Ok, IActionResult (m, n) => { - return await _service.DeleteAsyncByGroupUserId(groupId, userId).ThenAsync(Ok, IActionResult (m, n) => - { - _logger.LogNotice(n); - return StatusCode(StatusCodes.Status500InternalServerError); - }); - } - catch (Exception ex) - { - _logger.LogError(ex, "{Message}", ex.Message); + _logger.LogNotice(n); return StatusCode(StatusCodes.Status500InternalServerError); - } + }); } [NonAction] public override Task GetAll() => base.GetAll(); [HttpGet] - public async Task GetAll([FromQuery]bool withUser = false, [FromQuery]bool withGroup = false, [FromQuery] string? username = null) + public async Task GetAll([FromQuery] bool withUser = false, [FromQuery] bool withGroup = false, [FromQuery] string? username = null) { - try - { - if (username is not null) - return await _service.ReadByUsernameAsync(username).ThenAsync(Ok, IActionResult (m, n) => - { - _logger.LogNotice(n); - return NotFound(); - }); - - return await _service.ReadAllAsyncWith(withUser, withGroup).ThenAsync(Ok, IActionResult (m, n) => + if (username is not null) + return await _service.ReadByUsernameAsync(username).ThenAsync(Ok, IActionResult (m, n) => { _logger.LogNotice(n); return NotFound(); }); - } - catch(Exception ex) + + return await _service.ReadAllAsyncWith(withUser, withGroup).ThenAsync(Ok, IActionResult (m, n) => { - _logger.LogError(ex, "{Message}", ex.Message); - return StatusCode(StatusCodes.Status500InternalServerError); - } + _logger.LogNotice(n); + return NotFound(); + }); } [HttpGet("Has")] public async Task HasGroup([FromQuery] string username, [FromQuery] string groupname) { - try + return await _service.HasGroup(username, groupname).ThenAsync(Ok, (m, n) => { - return await _service.HasGroup(username, groupname).ThenAsync(Ok, (m, n) => - { - _logger.LogNotice(n); - return StatusCode(StatusCodes.Status500InternalServerError); - }); - } - catch(Exception ex) - { - _logger.LogError(ex, "{Message}", ex.Message); + _logger.LogNotice(n); return StatusCode(StatusCodes.Status500InternalServerError); - } + }); } } \ No newline at end of file