Files
xIdentityService/Interfaces/IXIdentityBaseReferencedProvider.cs
2025-12-20 01:25:24 +03:30

145 lines
4.7 KiB
C#

using System.Collections.Generic;
using System.Threading.Tasks;
using xDataService.Models;
using xIdentityModels.Models;
using xModels.Dtos;
namespace xIdentityService.Interfaces
{
/// <summary>
/// in Some Cases we have Entities Which Can Referenced for Specified
/// Provider and Types ...
/// this interface Globaly introduce all available Actions for those ...
///
/// TKey: type of Provider Models Keys ...
/// TModel: type of Dto which Referenced ...
/// </summary>
public interface IXIdentityBaseReferencedProvider<TModel, TKey>
{
//
#region Props ...
/// <summary>
/// Provider Identifier ...
/// </summary>
string Provider { get; }
#endregion
//
#region Referenced Actions ...
/// <summary>
/// Get Specified Indexed Reference for Specific Provided ID ...
/// </summary>
/// <param name="providedForId"></param>
/// <param name="forIndex"></param>
/// <returns></returns>
Task<TModel> GetReference(
TKey providedForId,
int forIndex = 0
);
/// <summary>
/// Retrieve all Exists References of Specific Provided ID ...
/// </summary>
/// <param name="providedForId"></param>
/// <returns></returns>
Task<IEnumerable<TModel>> GetAllReferences(TKey providedForId);
/// <summary>
/// Extract all Referencing Models for Specified Key ...
/// </summary>
/// <param name="providedForId"></param>
/// <returns></returns>
Task<IEnumerable<XReference<TKey>>> GetAllReferencings(TKey providedForId);
/// <summary>
/// Count References ...
/// </summary>
/// <param name="providedForId"></param>
/// <returns></returns>
Task<int> CountReferences(TKey providedForId);
/// <summary>
/// Retrieve References of Specific Provided ID as Query ...
/// </summary>
/// <param name="providedForId"></param>
/// <returns></returns>
Task<XQueryResult<TModel>> QueryReferences(
XQuery query,
TKey providedForId
);
/// <summary>
/// Add Reference a Model to Specific Provided ID ...
/// </summary>
/// <param name="model"></param>
/// <param name="providedForId"></param>
/// <param name="connectionId"></param>
/// <param name="userInfo"></param>
/// <returns></returns>
Task<bool> AddReference(
TModel model,
TKey providedForId,
string connectionId = null,
XUserClaimsInfoDto userInfo = null
);
/// <summary>
/// Add Reference a Model to Specific XRefence<TKey> ...
/// </summary>
/// <param name="model"></param>
/// <param name="reference"></param>
/// <param name="connectionId"></param>
/// <param name="userInfo"></param>
/// <returns></returns>
Task<bool> AddReference(
TModel model,
XReference<TKey> reference,
string connectionId = null,
XUserClaimsInfoDto userInfo = null
);
/// <summary>
/// Remove Reference a Model for Specific Provided ID ...
/// </summary>
/// <param name="model"></param>
/// <param name="providedForId"></param>
/// <param name="connectionId"></param>
/// <param name="userInfo"></param>
/// <returns></returns>
Task<bool> RemoveReference(
TModel model,
TKey providedForId,
string connectionId = null,
XUserClaimsInfoDto userInfo = null
);
/// <summary>
/// Remove Reference a Model for Specific XRefence<TKey> ...
/// </summary>
/// <param name="model"></param>
/// <param name="providedForId"></param>
/// <param name="connectionId"></param>
/// <param name="userInfo"></param>
/// <returns></returns>
Task<bool> RemoveReference(
TModel model,
XReference<TKey> reference,
string connectionId = null,
XUserClaimsInfoDto userInfo = null
);
/// <summary>
/// Remove All References to Specified Key ...
/// </summary>
/// <param name="providedForId"></param>
/// <param name="connectionId"></param>
/// <param name="userInfo"></param>
/// <returns></returns>
Task<bool> RemoveReferences(
TKey providedForId,
string connectionId = null,
XUserClaimsInfoDto userInfo = null
);
#endregion
}
}