This commit is contained in:
2026-05-28 16:16:44 +03:30
parent db03b59cc8
commit 6101d25a7b
3 changed files with 110 additions and 13 deletions
+58 -11
View File
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
@@ -18,6 +19,8 @@ namespace xFileService.Providers
{
public class XFileProvider : XBaseProvidedHasTag<XFile, XFileDto, Guid, XFileDtoHub>, IXFileProvider
{
private readonly IXFileServiceProvider provider;
public XFileProvider(
IXFileTagProvider tagProvider,
IXFileServiceProvider provider
@@ -26,10 +29,12 @@ namespace xFileService.Providers
tagProvider: tagProvider,
permittedRoles: new string[] { "admin" }
)
{ }
{
this.provider = provider;
}
public override bool IsOwned(
XFile item,
XFile item,
XUserClaimsInfoDto userInfo
)
{
@@ -45,7 +50,7 @@ namespace xFileService.Providers
}
public override bool IsOwned(
XFileDto item,
XFileDto item,
XUserClaimsInfoDto userInfo
)
{
@@ -68,9 +73,9 @@ namespace xFileService.Providers
/// <param name="providedFor"></param>
/// <param name="forProvidedId"></param>
/// <returns></returns>
public string GetIdentifier<TKey>(
public string GetIdentifier<TReferenceKey>(
string providedFor,
TKey forProvidedId
TReferenceKey forProvidedId
)
{
//
@@ -88,9 +93,9 @@ namespace xFileService.Providers
/// <param name="id"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task<bool> IsProvidedFor<TKey>(
public async Task<bool> IsProvidedFor<TReferenceKey>(
string providedFor,
TKey forProvidedId,
TReferenceKey forProvidedId,
Guid id,
CancellationToken cancellationToken = default
)
@@ -155,9 +160,9 @@ namespace xFileService.Providers
/// <param name="connectionId"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task AddReference<TKey>(
public async Task AddReference<TReferenceKey>(
string providedFor,
TKey forProvidedId,
TReferenceKey forProvidedId,
Guid id,
int forIndex = 0,
XUserClaimsInfoDto userInfo = null,
@@ -239,9 +244,9 @@ namespace xFileService.Providers
/// <param name="connectionId"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task RemoveReference<TKey>(
public async Task RemoveReference<TReferenceKey>(
string providedFor,
TKey forProvidedId,
TReferenceKey forProvidedId,
Guid id,
int forIndex = 0,
XUserClaimsInfoDto userInfo = null,
@@ -317,6 +322,48 @@ namespace xFileService.Providers
cancellationToken: cancellationToken
);
}
/// <summary>
/// Get Specified References ...
/// </summary>
/// <param name="providedFor"></param>
/// <param name="id"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task<IEnumerable<XReference<string>>> GetReferences(
string providedFor,
Guid id,
CancellationToken cancellationToken = default
)
{
//
IList<XReference<string>> result = new List<XReference<string>>();
//
var item = await provider.GetAsync(
id: id,
includeBuilder: null,
ignoreSoftDeleteds: true,
cancellationToken: cancellationToken
);
var isValid = !item.IsNullOrDefault();
if (!isValid)
{
return result;
}
//
result = item.GetReferences();
//
result = result.Where(r =>
r.ProvidedFor == providedFor
)
.ToList();
//
return result;
}
#endregion
}
}