using System;
using xIdentityHelper;
using System.Threading;
using xCommons.Extensions;
using xIdentityModels.Dtos;
using xExceptions.Constants;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
namespace xIds.Controllers
{
public partial class AuthorizationController
{
///
/// Retrieve Specified Role By Id ...
///
///
///
///
[HttpGet("Roles/{id}")]
[Authorize(Policy = XPolicies.EnabledAdmin)]
public virtual async Task> Get(
[FromRoute] int id,
CancellationToken cancellationToken = default
)
{
//
try
{
//
// Validate ...
if (!id.IsValidIntId())
{
XException.InvalidArgs.Throw();
}
//
var userInfo = await GetUserInfo();
//
var result = await roleProvider.GetAsync(
id: id,
ignoreSoftDeleteds: true,
cancellationToken: cancellationToken
);
//
return Ok(result.ToDynamicObject());
}
catch (Exception ex)
{
//
var result = GetExceptionActionResult(ex);
return result;
}
}
}
}