Delet RemoveFiles related Actions ...
This commit is contained in:
@@ -242,90 +242,6 @@ namespace xFileService.Providers
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove Specified Files ...
|
||||
/// </summary>
|
||||
/// <param name="providedForId"></param>
|
||||
/// <param name="ids">if null, Remove all Files</param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IEnumerable<Guid>> RemoveFiles(
|
||||
TKey providedForId,
|
||||
string ids = null,
|
||||
string connectionId = null,
|
||||
XUserClaimsInfoDto userInfo = null
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
if (providedForId.IsNull())
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
// Parse Provided IDS ...
|
||||
var idsList = new List<Guid>();
|
||||
IEnumerable<XFile> entities = null;
|
||||
if (!ids.IsNullOrEmpty())
|
||||
{
|
||||
//
|
||||
idsList = ids
|
||||
.ParseListGuid()
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
var identifier = GetProvidedID(providedForId);
|
||||
|
||||
//
|
||||
// Select All Referenced Files ...
|
||||
idsList = FileProvider.FileRepository
|
||||
.AsQueryable()
|
||||
.Where(f => f.References.Contains(identifier))
|
||||
.Select(f => f.Id)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve Entities ...
|
||||
entities = FileProvider.FileRepository
|
||||
.AsQueryable()
|
||||
.Where(d => idsList.Contains(d.Id) &&
|
||||
d.References.Contains(Provider));
|
||||
|
||||
//
|
||||
var result = new List<Guid>();
|
||||
var isValid = !entities.IsNull() && entities.HasChild();
|
||||
if (isValid)
|
||||
{
|
||||
//
|
||||
foreach (var entity in entities)
|
||||
{
|
||||
//
|
||||
// Remove File ...
|
||||
var idsToRemove = new List<string> { entity.Id.ToString() }.ToListString();
|
||||
var removeIds = await FileProvider.Remove(
|
||||
ids: idsToRemove,
|
||||
userInfo: userInfo,
|
||||
connectionId: connectionId
|
||||
);
|
||||
isValid = !removeIds.IsNull() &&
|
||||
removeIds.HasChild() &&
|
||||
removeIds.Contains(entity.Id);
|
||||
if (isValid)
|
||||
{
|
||||
result.Add(entity.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve Specified File Streaming Info ...
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user