using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using xCommons.Attributes;
using xCommons.Extensions;
using xIdentityHelper;
using xIdentityModels.Dtos;
using xModels.Dtos;
namespace xApi.Controllers
{
public partial class AccountController
{
//
#region Actions ...
///
/// Query Open To Search Users Profiles ...
/// Query all Users Which their Profiles is Open To Search ...
///
/// how to filter results based on XQuery structure
/// an instance of XQueryResult of XUserProfileDto
[RequireXPowered]
[HttpGet("OpenToSearch/Query")]
[Authorize(Policy = XPolicies.EnabledUser)]
public async Task>> QueryOpenToSearchProfiles(
[FromQuery] XQuery query
)
{
//
// Do Action ...
try
{
//
var tokens = await RetrieveTokensAsXTokenResponse();
var result = await identityProvider.QueryOpenToSearchUsers(
tokens,
query
);
//
return Ok(result
.ToDynamicObject());
}
catch (Exception ex)
{
//
var exception = GetExceptionActionResult(ex);
return exception;
}
}
#endregion
}
}