last works ...
This commit is contained in:
@@ -15,6 +15,7 @@ using xWebinarService.Models.Dtos;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using XFileDto = xFileService.Models.Dtos.XFileDto;
|
||||
using xModels.Dtos;
|
||||
using xTagService.Models.Dtos;
|
||||
|
||||
namespace xWebinarService.Controllers
|
||||
{
|
||||
@@ -85,7 +86,8 @@ namespace xWebinarService.Controllers
|
||||
//
|
||||
// Preparing Tags List ...
|
||||
var tagList = new List<string>();
|
||||
if (!tags.IsNullOrEmpty()) {
|
||||
if (!tags.IsNullOrEmpty())
|
||||
{
|
||||
tagList = tags
|
||||
.ParseListString<string>()
|
||||
.ToList();
|
||||
@@ -901,8 +903,8 @@ namespace xWebinarService.Controllers
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attach Provided Files to Specified Webinar ...
|
||||
@@ -1009,12 +1011,12 @@ namespace xWebinarService.Controllers
|
||||
var connectionId = GetConnectionId();
|
||||
|
||||
//
|
||||
var tagsList = tags.ParseListString<string>();
|
||||
await WebinarProvider
|
||||
.AttachTags(
|
||||
id: id,
|
||||
tags: tagsList,
|
||||
tags: tags,
|
||||
userInfo: userInfo,
|
||||
forceAttachToFiles: true,
|
||||
connectionId: connectionId
|
||||
);
|
||||
|
||||
@@ -1033,7 +1035,7 @@ namespace xWebinarService.Controllers
|
||||
/// Detach Specified Tags From Specified Webinar ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="tags"></param>
|
||||
/// <param name="tags">if null, remove all attached tags ...</param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("{id}/Tags")]
|
||||
public virtual async Task<ActionResult> DetachTags(
|
||||
@@ -1051,12 +1053,12 @@ namespace xWebinarService.Controllers
|
||||
var connectionId = GetConnectionId();
|
||||
|
||||
//
|
||||
var tagsList = tags.ParseListString<string>();
|
||||
await WebinarProvider
|
||||
.DetachTags(
|
||||
id: id,
|
||||
tags: tagsList,
|
||||
tags: tags,
|
||||
userInfo: userInfo,
|
||||
forceDetachFromFiles: true,
|
||||
connectionId: connectionId
|
||||
);
|
||||
|
||||
@@ -1077,7 +1079,7 @@ namespace xWebinarService.Controllers
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{id}/Tags")]
|
||||
public virtual async Task<ActionResult<IEnumerable<string>>> GetTags(
|
||||
public virtual async Task<ActionResult<IEnumerable<XTagDto>>> GetTags(
|
||||
[FromRoute] Guid id
|
||||
)
|
||||
{
|
||||
@@ -1090,14 +1092,15 @@ namespace xWebinarService.Controllers
|
||||
var userInfo = await GetUserInfo();
|
||||
|
||||
//
|
||||
await WebinarProvider
|
||||
var result = await WebinarProvider
|
||||
.GetTags(
|
||||
id: id,
|
||||
userInfo: userInfo
|
||||
);
|
||||
|
||||
//
|
||||
return Ok();
|
||||
return Ok(result
|
||||
.ToDynamicObject());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -9,6 +9,7 @@ using xDataService.Configuration;
|
||||
using xIdentityModels.Models;
|
||||
using xIdentityService.Interfaces;
|
||||
using xModels.Dtos;
|
||||
using xTagService.Models.Dtos;
|
||||
using xWebinarService.Hubs;
|
||||
using xWebinarService.Interfaces.Entities;
|
||||
using xWebinarService.Models.Dtos;
|
||||
@@ -314,17 +315,17 @@ namespace xWebinarService.Interfaces
|
||||
/// <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>
|
||||
Task AttachTag(
|
||||
string tag,
|
||||
Guid id,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
string tag,
|
||||
string connectionId = null,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
bool forceAttachToFiles = true
|
||||
);
|
||||
|
||||
@@ -338,58 +339,44 @@ namespace xWebinarService.Interfaces
|
||||
/// <param name="forceAttachToFiles"></param>
|
||||
/// <returns></returns>
|
||||
Task DetachTag(
|
||||
string tag,
|
||||
Guid id,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
string tag,
|
||||
string connectionId = null,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
bool forceDetachFromFiles = true
|
||||
);
|
||||
|
||||
/// <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>
|
||||
Task AttachTags(
|
||||
IEnumerable<string> tags,
|
||||
Guid id,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
string tags,
|
||||
string connectionId = null,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
bool forceAttachToFiles = true
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Detach Tags for Specified File ...
|
||||
/// </summary>
|
||||
/// <param name="tags"></param>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="tags">if nulls, detach all tags ...</param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="forceDetachFromFiles"></param>
|
||||
/// <returns></returns>
|
||||
Task DetachTags(
|
||||
IEnumerable<string> tags,
|
||||
Guid id,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
string connectionId = null,
|
||||
bool forceDetachFromFiles = true
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Detach all Attached Tags for Specified File ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="forceDetachFromFiles"></param>
|
||||
/// <returns></returns>
|
||||
Task DetachTags(
|
||||
Guid id,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
string tags,
|
||||
string connectionId = null,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
bool forceDetachFromFiles = true
|
||||
);
|
||||
|
||||
@@ -399,7 +386,7 @@ namespace xWebinarService.Interfaces
|
||||
/// <param name="id"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<string>> GetTags(
|
||||
Task<IEnumerable<XTagDto>> GetTags(
|
||||
Guid id,
|
||||
XUserClaimsInfoDto userInfo = null
|
||||
);
|
||||
|
||||
@@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using xModels.Dtos;
|
||||
using XFileDto = xFileService.Models.Dtos.XFileDto;
|
||||
using xWebinarService.Models.Dtos;
|
||||
using xTagService.Models.Dtos;
|
||||
|
||||
namespace xWebinarService.Interfaces
|
||||
{
|
||||
@@ -245,7 +246,7 @@ namespace xWebinarService.Interfaces
|
||||
/// Detach Specified Tags From Specified Webinar ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="tags"></param>
|
||||
/// <param name="tags">if null, remove all attached tags ...</param>
|
||||
/// <returns></returns>
|
||||
Task<ActionResult> DetachTags(
|
||||
[FromRoute] Guid id,
|
||||
@@ -257,7 +258,7 @@ namespace xWebinarService.Interfaces
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task<ActionResult<IEnumerable<string>>> GetTags(
|
||||
Task<ActionResult<IEnumerable<XTagDto>>> GetTags(
|
||||
[FromRoute] Guid id
|
||||
);
|
||||
#endregion
|
||||
|
||||
+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