Files
xSaherElmIds/Controllers/Account/AccountController+Search.cs
2026-03-22 14:08:25 +03:30

62 lines
1.9 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
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;
using static IdentityServer4.IdentityServerConstants;
namespace xIds.Controllers
{
/// <summary>
/// Actions which related to Search and Suggest Users for
/// Friendship or Detecting ...
/// </summary>
public partial class AccountController
{
//
#region Actions of Search ...
/// <summary>
/// Query Open To Search Users Profiles ...
/// Query all Users Which their Profiles is Open To Search ...
/// </summary>
/// <param name="query">how to filter results based on <see>XQuery</see> structure</param>
/// <returns>an instance of <see>XQueryResult</see> of <see>XUserProfileDto</see></returns>
[RequireXPowered]
[HttpGet("OpenToSearch/Query")]
[Authorize(Policy = LocalApi.PolicyName)]
[Authorize(Policy = XPolicies.EnabledUser)]
public async Task<ActionResult<XQueryResult<XUserProfileDto>>> QueryOpenToSearchProfiles(
[FromQuery] XQuery query)
{
//
// Do Action ...
try
{
//
var userId = User.Identity.Name;
//
var result = await IdentityManager.QueryOpenToSearchUsers(
userId,
query
);
return Ok(result
.ToDynamicObject());
}
catch (Exception ex)
{
//
var exception = GetExceptionActionResult(ex);
return exception;
}
}
#endregion
}
}