Update for Better Supports ...
This commit is contained in:
@@ -22,18 +22,12 @@ namespace xFileService.Interfaces
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Specified Provider ...
|
/// Specified Provider ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
string ProvideFor { get; }
|
string ProvidedFor { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Specified Provider Repositroy ...
|
/// Specified Provider Repositroy ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
IXFileProvider Provider { get; }
|
IXFileProvider Provider { get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Tag Provider for Specified File ...
|
|
||||||
/// </summary>
|
|
||||||
/// <value></value>
|
|
||||||
IXBaseTagProvider<TKey> TagProvider { get; }
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -47,7 +41,7 @@ namespace xFileService.Interfaces
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
//
|
//
|
||||||
#region Implementation ...
|
#region Tools ...
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stream Specified File ...
|
/// Stream Specified File ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -60,7 +54,7 @@ namespace xFileService.Interfaces
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="fileName"></param>
|
/// <param name="fileName"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<FileStreamResult> Stream(string fileName);
|
Task<FileStreamResult> Stream(string fileName);
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -80,10 +74,12 @@ namespace xFileService.Interfaces
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Upload Files ...
|
/// Upload Files ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="forProvidedId"></param>
|
||||||
/// <param name="files"></param>
|
/// <param name="files"></param>
|
||||||
/// <param name="userInfo"></param>
|
/// <param name="userInfo"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<IEnumerable<XFileDto>> Upload(
|
Task<IEnumerable<XFileDto>> Upload(
|
||||||
|
TKey forProvidedId,
|
||||||
IFormFileCollection files,
|
IFormFileCollection files,
|
||||||
XUserClaimsInfoDto userInfo = null
|
XUserClaimsInfoDto userInfo = null
|
||||||
);
|
);
|
||||||
@@ -91,10 +87,12 @@ namespace xFileService.Interfaces
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Remove Specified Files ...
|
/// Remove Specified Files ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="forProvidedId"></param>
|
||||||
/// <param name="ids"></param>
|
/// <param name="ids"></param>
|
||||||
/// <param name="userInfo"></param>
|
/// <param name="userInfo"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<IEnumerable<Guid>> Remove(
|
Task<IEnumerable<Guid>> Remove(
|
||||||
|
TKey forProvidedId,
|
||||||
string ids,
|
string ids,
|
||||||
XUserClaimsInfoDto userInfo = null
|
XUserClaimsInfoDto userInfo = null
|
||||||
);
|
);
|
||||||
@@ -120,7 +118,6 @@ namespace xFileService.Interfaces
|
|||||||
/// Get Specified File Model ...
|
/// Get Specified File Model ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
/// <param name="ignoreSoftDeleteds"></param>
|
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<XFileDto> Get(
|
Task<XFileDto> Get(
|
||||||
Guid id
|
Guid id
|
||||||
@@ -133,6 +130,13 @@ namespace xFileService.Interfaces
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<IEnumerable<XFileDto>> GetAll();
|
Task<IEnumerable<XFileDto>> GetAll();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get All Exists File Models ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="forProvidedId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<IEnumerable<XFileDto>> GetAllFor(TKey forProvidedId);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// find an Entity by providing a Conditional Expression ...
|
/// find an Entity by providing a Conditional Expression ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ namespace xFileService.Interfaces
|
|||||||
/// <param name="userInfo"></param>
|
/// <param name="userInfo"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task TagAttach(
|
Task TagAttach(
|
||||||
string tag,
|
string tag,
|
||||||
Guid id,
|
Guid id,
|
||||||
XUserClaimsInfoDto userInfo = null
|
XUserClaimsInfoDto userInfo = null
|
||||||
);
|
);
|
||||||
@@ -77,7 +77,7 @@ namespace xFileService.Interfaces
|
|||||||
/// <param name="userInfo"></param>
|
/// <param name="userInfo"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task TagDetach(
|
Task TagDetach(
|
||||||
string tag,
|
string tag,
|
||||||
Guid id,
|
Guid id,
|
||||||
XUserClaimsInfoDto userInfo = null
|
XUserClaimsInfoDto userInfo = null
|
||||||
);
|
);
|
||||||
@@ -90,7 +90,7 @@ namespace xFileService.Interfaces
|
|||||||
/// <param name="userInfo"></param>
|
/// <param name="userInfo"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task TagsAttach(
|
Task TagsAttach(
|
||||||
IEnumerable<string> tags,
|
IEnumerable<string> tags,
|
||||||
Guid id,
|
Guid id,
|
||||||
XUserClaimsInfoDto userInfo = null
|
XUserClaimsInfoDto userInfo = null
|
||||||
);
|
);
|
||||||
@@ -103,11 +103,11 @@ namespace xFileService.Interfaces
|
|||||||
/// <param name="userInfo"></param>
|
/// <param name="userInfo"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task TagsDetach(
|
Task TagsDetach(
|
||||||
IEnumerable<string> tags,
|
IEnumerable<string> tags,
|
||||||
Guid id,
|
Guid id,
|
||||||
XUserClaimsInfoDto userInfo = null
|
XUserClaimsInfoDto userInfo = null
|
||||||
);
|
);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Detach all Attached Tags for Specified File ...
|
/// Detach all Attached Tags for Specified File ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -193,20 +193,23 @@ namespace xFileService.Interfaces
|
|||||||
/// Get Reference Identifier for Specified Provider and Specified File ...
|
/// Get Reference Identifier for Specified Provider and Specified File ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="providedFor"></param>
|
/// <param name="providedFor"></param>
|
||||||
/// <param name="id"></param>
|
/// <param name="forProvidedId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
string GetIdentifier(
|
string GetIdentifier<TKey>(
|
||||||
string providedFor,
|
string providedFor,
|
||||||
Guid id
|
TKey forProvidedId
|
||||||
);
|
);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check Specified File has Refernce to Provider ...
|
/// Check Specified File has Refernce to Provider ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="providedFor"></param>
|
/// <param name="providedFor"></param>
|
||||||
|
/// <param name="forProvidedId"></param>
|
||||||
|
/// <param name="id"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<bool> IsProvidedFor(
|
Task<bool> IsProvidedFor<TKey>(
|
||||||
string providedFor,
|
string providedFor,
|
||||||
|
TKey forProvidedId,
|
||||||
Guid id
|
Guid id
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -214,11 +217,13 @@ namespace xFileService.Interfaces
|
|||||||
/// Add Specified Reference to Specified File ...
|
/// Add Specified Reference to Specified File ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="providedFor"></param>
|
/// <param name="providedFor"></param>
|
||||||
|
/// <param name="forProvidedId"></param>
|
||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
/// <param name="userInfo"></param>
|
/// <param name="userInfo"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task AddReference(
|
Task AddReference<TKey>(
|
||||||
string providedFor,
|
string providedFor,
|
||||||
|
TKey forProvidedId,
|
||||||
Guid id,
|
Guid id,
|
||||||
XUserClaimsInfoDto userInfo = null
|
XUserClaimsInfoDto userInfo = null
|
||||||
);
|
);
|
||||||
@@ -227,11 +232,13 @@ namespace xFileService.Interfaces
|
|||||||
/// Remove Specified Reference from Specified File ...
|
/// Remove Specified Reference from Specified File ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="providedFor"></param>
|
/// <param name="providedFor"></param>
|
||||||
|
/// <param name="forProvidedId"></param>
|
||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
/// <param name="userInfo"></param>
|
/// <param name="userInfo"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task RemoveReference(
|
Task RemoveReference<TKey>(
|
||||||
string providedFor,
|
string providedFor,
|
||||||
|
TKey forProvidedId,
|
||||||
Guid id,
|
Guid id,
|
||||||
XUserClaimsInfoDto userInfo = null
|
XUserClaimsInfoDto userInfo = null
|
||||||
);
|
);
|
||||||
|
|||||||
+771
-10
@@ -1,33 +1,794 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using xCommons.Extensions;
|
||||||
|
using xExceptions.Constants;
|
||||||
using xFileService.Interfaces;
|
using xFileService.Interfaces;
|
||||||
using xTagService.Interfaces;
|
using xFileService.Models.Dtos;
|
||||||
|
using xFileService.Models.Entities;
|
||||||
|
using xIdentityModels.Models;
|
||||||
|
using xModels.Dtos;
|
||||||
|
using XFileDto = xFileService.Models.Dtos.XFileDto;
|
||||||
|
|
||||||
namespace xFileService.Providers
|
namespace xFileService.Providers
|
||||||
{
|
{
|
||||||
public class XBaseFileProvider<TKey> : IXBaseFileProvider<TKey>
|
public abstract class XBaseFileProvider<TKey> : IXBaseFileProvider<TKey>
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
#region Props ...
|
#region Props ...
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Specified Provider ...
|
/// Specified Provider ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string ProvideFor { get; }
|
public string ProvidedFor { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Specified Provider Repositroy ...
|
/// Specified Provider Repositroy ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IXFileProvider Provider { get; }
|
public IXFileProvider Provider { get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Tag Provider for Specified File ...
|
|
||||||
/// </summary>
|
|
||||||
/// <value></value>
|
|
||||||
public IXBaseTagProvider<TKey> TagProvider { get; }
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
//
|
||||||
|
#region Constructor ...
|
||||||
|
public XBaseFileProvider(
|
||||||
|
string providedFor,
|
||||||
|
IXFileProvider provider
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
Provider = provider;
|
||||||
|
ProvidedFor = providedFor;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
//
|
||||||
|
#region Helper ...
|
||||||
|
/// <summary>
|
||||||
|
/// Get Specified Identifier ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="forProvidedId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string GetIdentifier(TKey forProvidedId)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
return Provider.GetIdentifier(
|
||||||
|
providedFor: ProvidedFor,
|
||||||
|
forProvidedId: forProvidedId
|
||||||
|
);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
//
|
||||||
|
#region Tools ...
|
||||||
|
/// <summary>
|
||||||
|
/// Stream Specified File ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<FileStreamResult> Stream(Guid id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Check Validation and Owning ...
|
||||||
|
var isValid = await IsOwned(id);
|
||||||
|
if (!isValid)
|
||||||
|
{
|
||||||
|
XException.NotAllowed.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
var result = await Provider.Stream(id);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Stream Specified File ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fileName"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<FileStreamResult> Stream(string fileName)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
var isValid = !fileName.IsNullOrEmpty();
|
||||||
|
if (!isValid)
|
||||||
|
{
|
||||||
|
XException.InvalidArgs.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Retrieve Dto and also Checking Owned ...
|
||||||
|
var dto = await GetDto(fileName);
|
||||||
|
isValid = !dto.IsNullOrDefault();
|
||||||
|
if (!isValid)
|
||||||
|
{
|
||||||
|
XException.NotAllowed.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
var result = await Provider.Stream(fileName);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Download Specified File ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<PhysicalFileResult> Download(Guid id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
var isValid = await IsOwned(id);
|
||||||
|
if (!isValid)
|
||||||
|
{
|
||||||
|
XException.NotAllowed.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
var result = await Provider.Download(id);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Download Specified File ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fileName"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<PhysicalFileResult> Download(string fileName)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
var isValid = !fileName.IsNullOrEmpty();
|
||||||
|
if (!isValid)
|
||||||
|
{
|
||||||
|
XException.InvalidArgs.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Retrieve Dto and also Checking Owned ...
|
||||||
|
var dto = await GetDto(fileName);
|
||||||
|
isValid = !dto.IsNullOrDefault();
|
||||||
|
if (!isValid)
|
||||||
|
{
|
||||||
|
XException.NotAllowed.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
var result = await Provider.Download(fileName);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Upload Files ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="forProvidedId"></param>
|
||||||
|
/// <param name="files"></param>
|
||||||
|
/// <param name="userInfo"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<IEnumerable<XFileDto>> Upload(
|
||||||
|
TKey forProvidedId,
|
||||||
|
IFormFileCollection files,
|
||||||
|
XUserClaimsInfoDto userInfo = null
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
var isValid = !forProvidedId.IsNull();
|
||||||
|
if (!isValid)
|
||||||
|
{
|
||||||
|
XException.InvalidArgs.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Here we are Following Custom Senario ...
|
||||||
|
var dtos = await Provider.Upload(
|
||||||
|
files: files,
|
||||||
|
userInfo: userInfo
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate Dtos ...
|
||||||
|
isValid = !dtos.IsNull() && dtos.HasChild();
|
||||||
|
if (isValid)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
foreach (var dto in dtos)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
await AddReference(
|
||||||
|
id: dto.Id,
|
||||||
|
userInfo: userInfo,
|
||||||
|
forProvidedId: forProvidedId
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
var result = new List<XFileDto>();
|
||||||
|
|
||||||
|
//
|
||||||
|
isValid = !dtos.IsNull() && dtos.HasChild();
|
||||||
|
if (isValid)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
foreach (var dto in dtos)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var idto = await Provider.Get(dto.Id);
|
||||||
|
isValid = !idto.IsNullOrDefault() &&
|
||||||
|
await IsOwned(idto.Id);
|
||||||
|
if (isValid)
|
||||||
|
{
|
||||||
|
result.Add(idto);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove Specified Files ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="forProvidedId"></param>
|
||||||
|
/// <param name="ids"></param>
|
||||||
|
/// <param name="userInfo"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<IEnumerable<Guid>> Remove(
|
||||||
|
TKey forProvidedId,
|
||||||
|
string ids = null,
|
||||||
|
XUserClaimsInfoDto userInfo = null
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
var isValid = userInfo.IsNullOrDefault();
|
||||||
|
if (!isValid)
|
||||||
|
{
|
||||||
|
XException.InvalidArgs.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// if ids Provided, Find all id's Specified Dtos ...
|
||||||
|
// if not, gell all models which Owned and has Reference to forProvidedId ...
|
||||||
|
var dtos = await GetAll();
|
||||||
|
if (!forProvidedId.IsNull())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var identifier = GetIdentifier(forProvidedId);
|
||||||
|
dtos = dtos
|
||||||
|
.Where(e => e.References.Any(er => er.ToNormalString() == identifier.ToNormalString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Filter Provided IDS ...
|
||||||
|
if (!ids.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var idsList = ids.ParseListGuid();
|
||||||
|
dtos = dtos.Where(d => !idsList.Contains(d.Id));
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
var result = new List<Guid>();
|
||||||
|
isValid = !dtos.IsNullOrDefault() && dtos.HasChild();
|
||||||
|
if (isValid)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
foreach (var dto in dtos)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var dtoIds = new List<string> { dto.Id.ToString() }.ToListString();
|
||||||
|
var removeIds = await Provider.Remove(dtoIds, userInfo);
|
||||||
|
isValid = !removeIds.IsNull() && removeIds.HasChild() && removeIds.Contains(dto.Id);
|
||||||
|
if (isValid)
|
||||||
|
{
|
||||||
|
result.Add(dto.Id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieve Specified File Streaming Info ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<XFileStreamDescriptorDto> GetFileDescriptor(Guid id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
var isValid = !id.IsNull() && !id.IsDefaultGuid();
|
||||||
|
if (!isValid)
|
||||||
|
{
|
||||||
|
XException.InvalidArgs.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Owned ...
|
||||||
|
isValid = await IsOwned(id);
|
||||||
|
if (!isValid)
|
||||||
|
{
|
||||||
|
XException.NotAllowed.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
var result = await Provider.GetFileDescriptor(id);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieve Specified File Streaming Info ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fileName"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<XFileStreamDescriptorDto> GetFileDescriptor(string fileName)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
var isValid = !fileName.IsNullOrEmpty();
|
||||||
|
if (!isValid)
|
||||||
|
{
|
||||||
|
XException.InvalidArgs.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Owned ...
|
||||||
|
var dto = GetDto(fileName);
|
||||||
|
isValid = !dto.IsNullOrDefault();
|
||||||
|
if (!isValid)
|
||||||
|
{
|
||||||
|
XException.NotAllowed.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
var result = await Provider.GetFileDescriptor(fileName);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
//
|
||||||
|
#region Data Model ...
|
||||||
|
/// <summary>
|
||||||
|
/// Get Specified File Model ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<XFileDto> Get(
|
||||||
|
Guid id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
var isValid = !id.IsNull() && !id.IsDefaultGuid();
|
||||||
|
if (!isValid)
|
||||||
|
{
|
||||||
|
XException.InvalidArgs.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Owned ...
|
||||||
|
isValid = await IsOwned(id);
|
||||||
|
if (!isValid)
|
||||||
|
{
|
||||||
|
XException.NotAllowed.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
var result = await Provider.Get(id);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get All Exists File Models ...
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<IEnumerable<XFileDto>> GetAll()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = await Provider
|
||||||
|
.FindMany(e => e.References.ToNormalString().Contains(ProvidedFor.ToNormalString()));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get All Exists File Models ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="forProvidedId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<IEnumerable<XFileDto>> GetAllFor(TKey forProvidedId)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
if (forProvidedId.IsNull())
|
||||||
|
{
|
||||||
|
XException.InvalidArgs.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
var identifier = GetIdentifier(forProvidedId);
|
||||||
|
var result = await Provider
|
||||||
|
.FindMany(e => e.References.ToNormalString().Contains(identifier.ToNormalString()));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// find an Entity by providing a Conditional Expression ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="whereClause"></param>
|
||||||
|
public async Task<XFileDto> FindOne(Expression<Func<XFile, bool>> whereClause)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
if (whereClause.IsNull())
|
||||||
|
{
|
||||||
|
XException.InvalidArgs.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
var whereFunc = whereClause.Compile();
|
||||||
|
var result = await Provider
|
||||||
|
.FindOne(e => whereFunc(e) && e.References.ToNormalString().Contains(ProvidedFor.ToNormalString()));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// find a collection of Entities by proving a Conditional Expression ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="whereClause"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<IEnumerable<XFileDto>> FindMany(
|
||||||
|
Expression<Func<XFile, bool>> whereClause
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
if (whereClause.IsNull())
|
||||||
|
{
|
||||||
|
XException.InvalidArgs.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
var whereFunc = whereClause.Compile();
|
||||||
|
var result = await Provider
|
||||||
|
.FindMany(e => whereFunc(e) && e.References.ToNormalString().Contains(ProvidedFor.ToNormalString()));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// retrieve Entities based on XQuery Pagination structure ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="query"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<XQueryResult<XFileDto>> Query(
|
||||||
|
XQuery query
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Define Owning Conditions ...
|
||||||
|
Expression<Func<XFile, bool>> whereClause = e => e.References
|
||||||
|
.ToNormalString()
|
||||||
|
.Contains(ProvidedFor.ToNormalString());
|
||||||
|
|
||||||
|
//
|
||||||
|
var result = await Provider.ConditionalQuery(
|
||||||
|
query: query,
|
||||||
|
whereClause: whereClause
|
||||||
|
);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// retrieve Entities based on XQuery Pagination structure by providing a Conditional Expression ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="whereClause"></param>
|
||||||
|
/// <param name="query"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<XQueryResult<XFileDto>> ConditionalQuery(
|
||||||
|
Expression<Func<XFile, bool>> whereClause,
|
||||||
|
XQuery query
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
if (whereClause.IsNull())
|
||||||
|
{
|
||||||
|
XException.InvalidArgs.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prepare a Combination Where Condition ...
|
||||||
|
var whereFunc = whereClause.Compile();
|
||||||
|
Expression<Func<XFile, bool>> condition = e => whereFunc(e) &&
|
||||||
|
e.References.ToNormalString().Contains(ProvidedFor.ToNormalString());
|
||||||
|
|
||||||
|
//
|
||||||
|
var result = await Provider.ConditionalQuery(
|
||||||
|
query: query,
|
||||||
|
whereClause: condition
|
||||||
|
);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Update an Entity values ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <param name="item"></param>
|
||||||
|
/// <param name="userInfo"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<XFileDto> Update(
|
||||||
|
Guid id,
|
||||||
|
XFileDto item,
|
||||||
|
XUserClaimsInfoDto userInfo = null
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
var isValid =
|
||||||
|
!id.IsNull() &&
|
||||||
|
!id.IsDefaultGuid() &&
|
||||||
|
!item.IsNullOrDefault() &&
|
||||||
|
!userInfo.IsNullOrDefault();
|
||||||
|
if (!isValid)
|
||||||
|
{
|
||||||
|
XException.InvalidArgs.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate Own ...
|
||||||
|
isValid = await IsOwned(item.Id);
|
||||||
|
if (!isValid)
|
||||||
|
{
|
||||||
|
XException.NotAllowed.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
var result = await Provider.Update(item.Id, item, userInfo);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// remove an Entity ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item"></param>
|
||||||
|
/// <param name="userInfo"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<XFileDto> Remove(
|
||||||
|
Guid id,
|
||||||
|
XUserClaimsInfoDto userInfo = null
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
var isValid = !id.IsNull() &&
|
||||||
|
!id.IsDefaultGuid() &&
|
||||||
|
!userInfo.IsNullOrDefault();
|
||||||
|
if (!isValid)
|
||||||
|
{
|
||||||
|
XException.InvalidArgs.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate Owned ...
|
||||||
|
isValid = await IsOwned(id);
|
||||||
|
if (!isValid)
|
||||||
|
{
|
||||||
|
XException.NotAllowed.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
var result = await Provider.Remove(id, userInfo);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// count all exists Entities ...
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<int> Count()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = (await GetAll()).Count();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check an Entity exists or not ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<bool> IsExists(
|
||||||
|
Guid id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = await IsOwned(id);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
//
|
||||||
|
#region Private ...
|
||||||
|
/// <summary>
|
||||||
|
/// Check Specified Dto is Has Reference to Provider ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private async Task<bool> IsOwned(Guid id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
var result = !id.IsNull() && !id.IsDefaultGuid();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
XException.InvalidArgs.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Exists ...
|
||||||
|
result = await Provider.IsExists(id);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
XException.NotFound.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Retrieve Dto ...
|
||||||
|
var dto = await Provider.Get(id);
|
||||||
|
result = !dto.IsNullOrDefault();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
XException.ActionFailed.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = !dto.References.IsNull() &&
|
||||||
|
dto.References.HasChild() &&
|
||||||
|
dto.References.Any(r => r.ToNormalString().Contains(ProvidedFor.ToNormalString()));
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get Specified Owned Dto by File Name ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fileName"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private async Task<XFileDto> GetDto(string fileName)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XFileDto result = null;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (!fileName.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result = await Provider.FindOne(d =>
|
||||||
|
d.Name == fileName ||
|
||||||
|
d.Thumb == fileName ||
|
||||||
|
d.FileName == fileName ||
|
||||||
|
d.Path.Contains(fileName) ||
|
||||||
|
d.ThumbPath.Contains(fileName)
|
||||||
|
);
|
||||||
|
if (!result.IsNullOrDefault())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Check Owning ...
|
||||||
|
var isOwned = await IsOwned(result.Id);
|
||||||
|
if (!isOwned)
|
||||||
|
{
|
||||||
|
result = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get Specified Provided ID's Related Files ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="forProvidedId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private async Task<IEnumerable<XFileDto>> GetDtos(TKey forProvidedId)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = new List<XFileDto>();
|
||||||
|
|
||||||
|
//
|
||||||
|
var identifier = GetIdentifier(forProvidedId);
|
||||||
|
if (!forProvidedId.IsNull())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result = (await Provider
|
||||||
|
.FindMany(e => e.References.ToNormalString().Contains(identifier.ToNormalString())))
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check Specified File has Refernce to Provider ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="forProvidedId"></param>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private async Task<bool> IsProvidedFor(
|
||||||
|
TKey forProvidedId,
|
||||||
|
Guid id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = await Provider.IsProvidedFor(
|
||||||
|
id: id,
|
||||||
|
providedFor: ProvidedFor,
|
||||||
|
forProvidedId: forProvidedId
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Add Specified Reference to Specified File ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="forProvidedId"></param>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <param name="userInfo"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private async Task AddReference(
|
||||||
|
TKey forProvidedId,
|
||||||
|
Guid id,
|
||||||
|
XUserClaimsInfoDto userInfo = null
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
await Provider.AddReference(
|
||||||
|
id: id,
|
||||||
|
userInfo: userInfo,
|
||||||
|
providedFor: ProvidedFor,
|
||||||
|
forProvidedId: forProvidedId
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove Specified Reference from Specified File ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="forProvidedId"></param>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <param name="userInfo"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private async Task RemoveReference(
|
||||||
|
TKey forProvidedId,
|
||||||
|
Guid id,
|
||||||
|
XUserClaimsInfoDto userInfo = null
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
await Provider.RemoveReference(
|
||||||
|
id: id,
|
||||||
|
userInfo: userInfo,
|
||||||
|
providedFor: ProvidedFor,
|
||||||
|
forProvidedId: forProvidedId
|
||||||
|
);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+40
-13
@@ -918,23 +918,26 @@ namespace xFileService.Providers
|
|||||||
/// Get Reference Identifier for Specified Provider and Specified File ...
|
/// Get Reference Identifier for Specified Provider and Specified File ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="providedFor"></param>
|
/// <param name="providedFor"></param>
|
||||||
/// <param name="id"></param>
|
/// <param name="forProvidedId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string GetIdentifier(
|
public string GetIdentifier<TKey>(
|
||||||
string providedFor,
|
string providedFor,
|
||||||
Guid id
|
TKey forProvidedId
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return $"{providedFor}_{id}";
|
return $"{providedFor}_{forProvidedId}";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check Specified File has Refernce to Provider ...
|
/// Check Specified File has Refernce to Provider ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="providedFor"></param>
|
/// <param name="providedFor"></param>
|
||||||
|
/// <param name="forProvidedId"></param>
|
||||||
|
/// <param name="id"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<bool> IsProvidedFor(
|
public async Task<bool> IsProvidedFor<TKey>(
|
||||||
string providedFor,
|
string providedFor,
|
||||||
|
TKey forProvidedId,
|
||||||
Guid id
|
Guid id
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -943,7 +946,8 @@ namespace xFileService.Providers
|
|||||||
var isValid =
|
var isValid =
|
||||||
!providedFor.IsNullOrEmpty() &&
|
!providedFor.IsNullOrEmpty() &&
|
||||||
!id.IsNull() &&
|
!id.IsNull() &&
|
||||||
!id.IsDefaultGuid();
|
!id.IsDefaultGuid() &&
|
||||||
|
!forProvidedId.IsNull();
|
||||||
if (!isValid)
|
if (!isValid)
|
||||||
{
|
{
|
||||||
XException.InvalidArgs.Throw();
|
XException.InvalidArgs.Throw();
|
||||||
@@ -966,7 +970,10 @@ namespace xFileService.Providers
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
var identifier = GetIdentifier(providedFor, id);
|
var identifier = GetIdentifier(
|
||||||
|
providedFor: providedFor,
|
||||||
|
forProvidedId: forProvidedId
|
||||||
|
);
|
||||||
var result =
|
var result =
|
||||||
dto.References.IsNull() &&
|
dto.References.IsNull() &&
|
||||||
dto.References.HasChild() &&
|
dto.References.HasChild() &&
|
||||||
@@ -980,11 +987,13 @@ namespace xFileService.Providers
|
|||||||
/// Add Specified Reference to Specified File ...
|
/// Add Specified Reference to Specified File ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="providedFor"></param>
|
/// <param name="providedFor"></param>
|
||||||
|
/// <param name="forProvidedId"></param>
|
||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
/// <param name="userInfo"></param>
|
/// <param name="userInfo"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task AddReference(
|
public async Task AddReference<TKey>(
|
||||||
string providedFor,
|
string providedFor,
|
||||||
|
TKey forProvidedId,
|
||||||
Guid id,
|
Guid id,
|
||||||
XUserClaimsInfoDto userInfo = null
|
XUserClaimsInfoDto userInfo = null
|
||||||
)
|
)
|
||||||
@@ -995,6 +1004,7 @@ namespace xFileService.Providers
|
|||||||
!providedFor.IsNullOrEmpty() &&
|
!providedFor.IsNullOrEmpty() &&
|
||||||
!id.IsNull() &&
|
!id.IsNull() &&
|
||||||
!id.IsDefaultGuid() &&
|
!id.IsDefaultGuid() &&
|
||||||
|
!providedFor.IsNull() &&
|
||||||
!userInfo.IsNullOrDefault();
|
!userInfo.IsNullOrDefault();
|
||||||
if (!isValid)
|
if (!isValid)
|
||||||
{
|
{
|
||||||
@@ -1003,7 +1013,11 @@ namespace xFileService.Providers
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Check Has Reference or not ...
|
// Check Has Reference or not ...
|
||||||
isValid = await IsProvidedFor(providedFor, id);
|
isValid = await IsProvidedFor(
|
||||||
|
providedFor: providedFor,
|
||||||
|
forProvidedId: forProvidedId,
|
||||||
|
id: id
|
||||||
|
);
|
||||||
if (!isValid)
|
if (!isValid)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -1026,7 +1040,10 @@ namespace xFileService.Providers
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
var identifier = GetIdentifier(providedFor, id);
|
var identifier = GetIdentifier(
|
||||||
|
providedFor: providedFor,
|
||||||
|
forProvidedId: forProvidedId
|
||||||
|
);
|
||||||
dto.References.Add(identifier);
|
dto.References.Add(identifier);
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -1047,11 +1064,13 @@ namespace xFileService.Providers
|
|||||||
/// Remove Specified Reference from Specified File ...
|
/// Remove Specified Reference from Specified File ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="providedFor"></param>
|
/// <param name="providedFor"></param>
|
||||||
|
/// <param name="forProvidedId"></param>
|
||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
/// <param name="userInfo"></param>
|
/// <param name="userInfo"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task RemoveReference(
|
public async Task RemoveReference<TKey>(
|
||||||
string providedFor,
|
string providedFor,
|
||||||
|
TKey forProvidedId,
|
||||||
Guid id,
|
Guid id,
|
||||||
XUserClaimsInfoDto userInfo = null
|
XUserClaimsInfoDto userInfo = null
|
||||||
)
|
)
|
||||||
@@ -1062,6 +1081,7 @@ namespace xFileService.Providers
|
|||||||
!providedFor.IsNullOrEmpty() &&
|
!providedFor.IsNullOrEmpty() &&
|
||||||
!id.IsNull() &&
|
!id.IsNull() &&
|
||||||
!id.IsDefaultGuid() &&
|
!id.IsDefaultGuid() &&
|
||||||
|
!forProvidedId.IsNull() &&
|
||||||
!userInfo.IsNullOrDefault();
|
!userInfo.IsNullOrDefault();
|
||||||
if (!isValid)
|
if (!isValid)
|
||||||
{
|
{
|
||||||
@@ -1070,7 +1090,11 @@ namespace xFileService.Providers
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Check Has Reference or not ...
|
// Check Has Reference or not ...
|
||||||
isValid = await IsProvidedFor(providedFor, id);
|
isValid = await IsProvidedFor(
|
||||||
|
providedFor: providedFor,
|
||||||
|
forProvidedId: forProvidedId,
|
||||||
|
id: id
|
||||||
|
);
|
||||||
if (isValid)
|
if (isValid)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -1094,7 +1118,10 @@ namespace xFileService.Providers
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
var identifier = GetIdentifier(providedFor, id);
|
var identifier = GetIdentifier(
|
||||||
|
providedFor: providedFor,
|
||||||
|
forProvidedId: forProvidedId
|
||||||
|
);
|
||||||
dto.References = dto.References
|
dto.References = dto.References
|
||||||
.Where(r => r.ToNormalString() != identifier.ToNormalString())
|
.Where(r => r.ToNormalString() != identifier.ToNormalString())
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|||||||
@@ -9,10 +9,9 @@ namespace xFileService.Providers
|
|||||||
public class XFileTagProvider : XBaseTagProvider<Guid>, IXFileTagProvider
|
public class XFileTagProvider : XBaseTagProvider<Guid>, IXFileTagProvider
|
||||||
{
|
{
|
||||||
public XFileTagProvider(
|
public XFileTagProvider(
|
||||||
IXTagProvider tagProvider,
|
IXTagProvider tagProvider
|
||||||
string providedFor = nameof(XFile)
|
|
||||||
) : base(
|
) : base(
|
||||||
providedFor: providedFor,
|
providedFor: nameof(XFile),
|
||||||
tagProvider: tagProvider
|
tagProvider: tagProvider
|
||||||
)
|
)
|
||||||
{ }
|
{ }
|
||||||
|
|||||||
Reference in New Issue
Block a user