Try-Catch zum GroupOfUserController hinzugefügt
This commit is contained in:
parent
66d6fa1f71
commit
cef098f265
@ -17,6 +17,8 @@ namespace DigitalData.UserManager.API.Controllers
|
|||||||
|
|
||||||
[HttpDelete]
|
[HttpDelete]
|
||||||
public async Task<IActionResult> Delete([FromQuery] int groupId, [FromQuery] int userId)
|
public async Task<IActionResult> Delete([FromQuery] int groupId, [FromQuery] int userId)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
var result = await _service.DeleteAsyncByGroupUserId(groupId, userId);
|
var result = await _service.DeleteAsyncByGroupUserId(groupId, userId);
|
||||||
if (result.IsSuccess)
|
if (result.IsSuccess)
|
||||||
@ -26,12 +28,20 @@ namespace DigitalData.UserManager.API.Controllers
|
|||||||
|
|
||||||
return BadRequest(result);
|
return BadRequest(result);
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "{Message}", ex.Message);
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[NonAction]
|
[NonAction]
|
||||||
public override Task<IActionResult> GetAll() => base.GetAll();
|
public override Task<IActionResult> GetAll() => base.GetAll();
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<IActionResult> GetAll([FromQuery]bool withUser = false, [FromQuery]bool withGroup = false)
|
public async Task<IActionResult> GetAll([FromQuery]bool withUser = false, [FromQuery]bool withGroup = false)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
var result = await _service.ReadAllAsyncWith(withUser, withGroup);
|
var result = await _service.ReadAllAsyncWith(withUser, withGroup);
|
||||||
if (result.IsSuccess)
|
if (result.IsSuccess)
|
||||||
@ -41,11 +51,25 @@ namespace DigitalData.UserManager.API.Controllers
|
|||||||
|
|
||||||
return NotFound(result);
|
return NotFound(result);
|
||||||
}
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "{Message}", ex.Message);
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[HttpGet("Has")]
|
[HttpGet("Has")]
|
||||||
public async Task<IActionResult> HasGroup([FromQuery] string username, [FromQuery] string groupname)
|
public async Task<IActionResult> HasGroup([FromQuery] string username, [FromQuery] string groupname)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
return Ok(await _service.HasGroup(username, groupname));
|
return Ok(await _service.HasGroup(username, groupname));
|
||||||
}
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "{Message}", ex.Message);
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user