last works ...
This commit is contained in:
+63
-109
@@ -17,6 +17,7 @@ using xIdentityService.Extensions;
|
||||
using xIdentityService.Interfaces;
|
||||
using xModels.Dtos;
|
||||
using xPushService.Constants;
|
||||
using xTagService.Models.Dtos;
|
||||
using xWebinarService.Constants;
|
||||
using xWebinarService.Hubs;
|
||||
using xWebinarService.Interfaces;
|
||||
@@ -334,11 +335,11 @@ namespace xWebinarService.Providers
|
||||
{
|
||||
//
|
||||
await AttachTags(
|
||||
tags: tags,
|
||||
id: entity.Id,
|
||||
userInfo: userInfo,
|
||||
connectionId: connectionId,
|
||||
true //
|
||||
forceAttachToFiles: true,
|
||||
tags: tags.ToListString(),
|
||||
connectionId: connectionId
|
||||
);
|
||||
}
|
||||
catch { }
|
||||
@@ -889,6 +890,7 @@ namespace xWebinarService.Providers
|
||||
//
|
||||
// Detach Tags ...
|
||||
await DetachTags(
|
||||
tags: null, // Pass Null to Detach All Referenced Tags ...
|
||||
id: entity.Id,
|
||||
userInfo: userInfo,
|
||||
connectionId: connectionId
|
||||
@@ -1665,7 +1667,6 @@ namespace xWebinarService.Providers
|
||||
await WebinarFileProvider.AddReference(
|
||||
model: file,
|
||||
providedForId: id,
|
||||
forIndex: 0,
|
||||
userInfo: userInfo,
|
||||
connectionId: connectionId
|
||||
);
|
||||
@@ -1764,25 +1765,26 @@ namespace xWebinarService.Providers
|
||||
/// <summary>
|
||||
/// Attach Tag to Specified File ...
|
||||
/// </summary>
|
||||
/// <param name="tag"></param>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <param name="tag"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <param name="forceAttachToFiles"></param>
|
||||
/// <returns></returns>
|
||||
public async Task AttachTag(
|
||||
string tag,
|
||||
Guid id,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
string tag,
|
||||
string connectionId = null,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
bool forceAttachToFiles = true
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
var isValid = !tag.IsNullOrEmpty() &&
|
||||
var isValid =
|
||||
!id.IsNull() &&
|
||||
!id.IsDefaultGuid() &&
|
||||
!tag.IsNullOrEmpty() &&
|
||||
!userInfo.IsNullOrDefault();
|
||||
if (!isValid)
|
||||
{
|
||||
@@ -1807,7 +1809,6 @@ namespace xWebinarService.Providers
|
||||
// Attached Tag to Webinar ...
|
||||
await WebinarTagProvider.AddReference(
|
||||
tag: tag,
|
||||
forIndex: 0,
|
||||
providedForId: id,
|
||||
connectionId: connectionId
|
||||
);
|
||||
@@ -1840,25 +1841,27 @@ namespace xWebinarService.Providers
|
||||
/// <summary>
|
||||
/// Detach Tag fro Specified File ...
|
||||
/// </summary>
|
||||
/// <param name="tag"></param>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <param name="tag"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <param name="forceAttachToFiles"></param>
|
||||
/// <returns></returns>
|
||||
public async Task DetachTag(
|
||||
string tag,
|
||||
Guid id,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
string tag,
|
||||
string connectionId = null,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
bool forceDetachFromFiles = true
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
var isValid = !tag.IsNullOrEmpty() &&
|
||||
var isValid =
|
||||
!id.IsNull() &&
|
||||
!id.IsDefaultGuid();
|
||||
!id.IsDefaultGuid() &&
|
||||
!tag.IsNullOrEmpty() &&
|
||||
!userInfo.IsNullOrDefault();
|
||||
if (!isValid)
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
@@ -1914,26 +1917,27 @@ namespace xWebinarService.Providers
|
||||
/// <summary>
|
||||
/// Attach Tags for Specified File ...
|
||||
/// </summary>
|
||||
/// <param name="tags"></param>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <param name="tags"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <param name="forceAttachToFiles"></param>
|
||||
/// <returns></returns>
|
||||
public async Task AttachTags(
|
||||
IEnumerable<string> tags,
|
||||
Guid id,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
string tags,
|
||||
string connectionId = null,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
bool forceAttachToFiles = true
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
var isValid = !tags.IsNull() &&
|
||||
tags.HasChild() &&
|
||||
var isValid =
|
||||
!id.IsNull() &&
|
||||
!id.IsDefaultGuid();
|
||||
!id.IsDefaultGuid() &&
|
||||
!tags.IsNullOrEmpty() &&
|
||||
!userInfo.IsNullOrDefault();
|
||||
if (!isValid)
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
@@ -1954,7 +1958,8 @@ namespace xWebinarService.Providers
|
||||
try
|
||||
{
|
||||
//
|
||||
foreach (var tag in tags)
|
||||
var tagsList = tags.ParseListString<string>();
|
||||
foreach (var tag in tagsList)
|
||||
{
|
||||
//
|
||||
await AttachTag(
|
||||
@@ -1972,26 +1977,26 @@ namespace xWebinarService.Providers
|
||||
/// <summary>
|
||||
/// Detach Tags for Specified File ...
|
||||
/// </summary>
|
||||
/// <param name="tags"></param>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <param name="tags">if null, Detach All ...</param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <param name="forceDetachFromFiles"></param>
|
||||
/// <returns></returns>
|
||||
public async Task DetachTags(
|
||||
IEnumerable<string> tags,
|
||||
Guid id,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
string tags,
|
||||
string connectionId = null,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
bool forceDetachFromFiles = true
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
var isValid = !tags.IsNull() &&
|
||||
tags.HasChild() &&
|
||||
var isValid =
|
||||
!id.IsNull() &&
|
||||
!id.IsDefaultGuid();
|
||||
!id.IsDefaultGuid() &&
|
||||
!userInfo.IsNullOrDefault();
|
||||
if (!isValid)
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
@@ -2008,11 +2013,26 @@ namespace xWebinarService.Providers
|
||||
XException.NotAllowed.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
IEnumerable<string> tagsList;
|
||||
if (!tags.IsNullOrEmpty())
|
||||
{
|
||||
//
|
||||
// Only Detach Provided Tags ...
|
||||
tagsList = tags.ParseListString<string>();
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Select all Referenced Tags ...
|
||||
tagsList = (await WebinarTagProvider.GetAllReferences(id)).Select(t => t.Tag);
|
||||
}
|
||||
|
||||
//
|
||||
try
|
||||
{
|
||||
//
|
||||
foreach (var tag in tags)
|
||||
foreach (var tag in tagsList)
|
||||
{
|
||||
//
|
||||
await DetachTag(
|
||||
@@ -2027,79 +2047,13 @@ namespace xWebinarService.Providers
|
||||
catch { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Detach all Attached Tags for Specified Webinar ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="forceDetachFromFiles"></param>
|
||||
/// <returns></returns>
|
||||
public async Task DetachTags(
|
||||
Guid id,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
string connectionId = null,
|
||||
bool forceDetachFromFiles = true
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
var isValid = !id.IsNull() && !id.IsDefaultGuid();
|
||||
if (!isValid)
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
// Check Permissions ...
|
||||
isValid = await HasPermission(
|
||||
id: id,
|
||||
userInfo: userInfo
|
||||
);
|
||||
if (!isValid)
|
||||
{
|
||||
XException.NotAllowed.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
try
|
||||
{
|
||||
//
|
||||
await WebinarTagProvider.RemoveReferences(
|
||||
providedForId: id,
|
||||
connectionId: connectionId
|
||||
);
|
||||
|
||||
//
|
||||
if (forceDetachFromFiles)
|
||||
{
|
||||
//
|
||||
var medias = await WebinarFileProvider.GetAllReferences(id);
|
||||
isValid = !medias.IsNull() && medias.HasChild();
|
||||
if (isValid)
|
||||
{
|
||||
//
|
||||
foreach (var media in medias)
|
||||
{
|
||||
//
|
||||
await WebinarFileProvider.FileProvider.TagProvider.RemoveReferences(
|
||||
providedForId: media.Id,
|
||||
connectionId: connectionId
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve Specified Webinar's Tags ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IEnumerable<string>> GetTags(
|
||||
public async Task<IEnumerable<XTagDto>> GetTags(
|
||||
Guid id,
|
||||
XUserClaimsInfoDto userInfo = null
|
||||
)
|
||||
@@ -2140,18 +2094,18 @@ namespace xWebinarService.Providers
|
||||
|
||||
//
|
||||
// Reading Tags Dto List ...
|
||||
var tagsDtos = await WebinarTagProvider.GetAllReferences(id);
|
||||
var result = await WebinarTagProvider.GetAllReferences(id);
|
||||
|
||||
//
|
||||
var result = new List<string>();
|
||||
isValid = !tagsDtos.IsNull() && tagsDtos.HasChild();
|
||||
if (isValid)
|
||||
{
|
||||
//
|
||||
result = tagsDtos
|
||||
.Select(td => td.Tag)
|
||||
.ToList();
|
||||
}
|
||||
// var result = new List<string>();
|
||||
// isValid = !tagsDtos.IsNull() && tagsDtos.HasChild();
|
||||
// if (isValid)
|
||||
// {
|
||||
// //
|
||||
// result = tagsDtos
|
||||
// .Select(td => td.Tag)
|
||||
// .ToList();
|
||||
// }
|
||||
|
||||
//
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user