diff --git a/Controllers/XWebinarServiceControllerBase.cs b/Controllers/XWebinarServiceControllerBase.cs
index dad4ad2..83a81fb 100644
--- a/Controllers/XWebinarServiceControllerBase.cs
+++ b/Controllers/XWebinarServiceControllerBase.cs
@@ -57,13 +57,6 @@ namespace xWebinarService.Controllers
///
///
///
- ///
- /// Create Webinar ...
- ///
- ///
- ///
- ///
- ///
[HttpPost("")]
public virtual async Task> CreateWebinar(
[FromForm] XWebinarDto item,
diff --git a/Interfaces/IXWebinarProvider.cs b/Interfaces/IXWebinarProvider.cs
index 796d1ce..6eed99f 100644
--- a/Interfaces/IXWebinarProvider.cs
+++ b/Interfaces/IXWebinarProvider.cs
@@ -89,12 +89,6 @@ namespace xWebinarService.Interfaces
///
Task GetWebinar(Guid id);
- ///
- /// Retrieve all Exists Webinar Ids ...
- ///
- ///
- IEnumerable GetWebinarIds();
-
///
/// Retrieve all Exists Webinars ...
///
@@ -139,13 +133,6 @@ namespace xWebinarService.Interfaces
XUserClaimsInfoDto userInfo = null
);
- ///
- /// Query Webinar Ids ...
- ///
- ///
- ///
- XQueryResult QueryWebinarIds(XQuery query);
-
///
/// Remove Specified Webinar ...
///
@@ -168,11 +155,13 @@ namespace xWebinarService.Interfaces
///
///
///
+ ///
///
Task Subscribe(
Guid webinarId,
string subscriberId,
- string connectionId = null
+ string connectionId = null,
+ XUserClaimsInfoDto userInfo = null
);
///
@@ -180,10 +169,12 @@ namespace xWebinarService.Interfaces
///
///
///
+ ///
///
Task IsSubscribed(
Guid webinarId,
- string subscriberId
+ string subscriberId,
+ XUserClaimsInfoDto userInfo = null
);
///
@@ -192,11 +183,13 @@ namespace xWebinarService.Interfaces
///
///
///
+ ///
///
Task Unsubscribe(
Guid webinarId,
string subscriberId,
- string connectionId = null
+ string connectionId = null,
+ XUserClaimsInfoDto userInfo = null
);
///
@@ -204,28 +197,36 @@ namespace xWebinarService.Interfaces
///
///
///
+ ///
///
Task GetSubscriber(
Guid webinarId,
- string subscriberId
+ string subscriberId,
+ XUserClaimsInfoDto userInfo = null
);
///
/// Get all Specified Webinars Subscribers ...
///
///
+ ///
///
- Task> GetSubscribers(Guid webinarId);
+ Task> GetSubscribers(
+ Guid webinarId,
+ XUserClaimsInfoDto userInfo = null
+ );
///
/// Query Specified Webinar's Subscribers ...
///
///
///
+ ///
///
Task> QuerySubscribers(
Guid webinarId,
- XQuery query
+ XQuery query,
+ XUserClaimsInfoDto userInfo = null
);
#endregion
@@ -265,8 +266,12 @@ namespace xWebinarService.Interfaces
/// Get Webinar Files ...
///
///
+ ///
///
- Task> GetFiles(Guid id);
+ Task> GetFiles(
+ Guid id,
+ XUserClaimsInfoDto userInfo = null
+ );
///
/// Stream Specified File ...
diff --git a/Providers/XWebinarFileProvider.cs b/Providers/XWebinarFileProvider.cs
index c0ff042..39adbc2 100644
--- a/Providers/XWebinarFileProvider.cs
+++ b/Providers/XWebinarFileProvider.cs
@@ -9,10 +9,10 @@ namespace xWebinarService.Providers
public class XWebinarFileProvider : XBaseFileProvider, IXWebinarFileProvider
{
public XWebinarFileProvider(
- IXFileProvider provider
+ IXFileProvider fileProvider
) : base(
providedFor: nameof(XWebinar),
- provider: provider
+ fileProvider: fileProvider
)
{ }
}
diff --git a/Providers/XWebinarProvider.cs b/Providers/XWebinarProvider.cs
index f329073..3a4be9c 100644
--- a/Providers/XWebinarProvider.cs
+++ b/Providers/XWebinarProvider.cs
@@ -3,9 +3,11 @@ using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
+using IdentityModel.Client;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR;
+using MongoDB.Driver;
using xCommons.Extensions;
using xDataService.Configuration;
using xDataService.Extensions;
@@ -549,21 +551,25 @@ namespace xWebinarService.Providers
public async Task> GetWebinars()
{
//
- var list = await WebinarRepository.GetAllAsync();
- var result = await list.SelectAsync(async l => await ToXWebinarDto(l));
+ var entities = WebinarRepository
+ .AsQueryable()
+ .ToList();
- //
- return result;
- }
-
- ///
- /// Retrieve all Exists Webinar Ids ...
- ///
- ///
- public IEnumerable GetWebinarIds()
- {
- //
- var result = WebinarRepository.AsQueryable().Select(l => l.Id);
+ //
+ var result = new List();
+ if (!entities.IsNull() && entities.HasChild())
+ {
+ //
+ foreach (var entity in entities)
+ {
+ //
+ var dto = await ToXWebinarDto(entity);
+ if (!dto.IsNullOrDefault())
+ {
+ result.Add(dto);
+ }
+ }
+ }
//
return result;
@@ -823,75 +829,6 @@ namespace xWebinarService.Providers
return result;
}
- ///
- /// Query Webinar Ids ...
- ///
- ///
- ///
- public XQueryResult QueryWebinarIds(XQuery query)
- {
- //
- // Validate ...
- if (query.IsNull())
- {
- XException.InvalidArgs.Throw();
- }
-
- //
- // Normalize ...
- query = query.NormalizeQuery(DataSercviceConfiguration);
-
- //
- // Since in Resourceable Entities we have to Search on Locales
- // we Must Implement Senario Custom ...
- var items = GetWebinarIds();
- var totalItemsCount = items.Count();
-
- //
- // Apply Filter ...
- if (!query.Filter.IsNullOrEmpty())
- {
- //
- items = items
- .Where(i => i.ToString().ToNormalString().Contains(query.Filter));
- }
- int filteredItemsCount = items.Count();
-
- //
- // Count Pages ...
- var totalPagesCount = query.CountPages(totalItemsCount);
- var filteredPagesCount = query.CountPages(filteredItemsCount);
-
- //
- // Apply Paging and Sorting ...
- if (totalItemsCount > 0 &&
- filteredItemsCount > 0)
- {
- //
- // Apply Paging ...
- items = items.ApplyPaging(
- query.Page,
- query.PageSize
- );
- }
-
- //
- // Prepare Result ...
- var result = new XQueryResult
- {
- Items = items,
- Page = query.Page,
- PageSize = query.PageSize,
- TotalPages = totalPagesCount,
- TotalItems = totalItemsCount,
- TotalFilteredPages = filteredPagesCount,
- TotalFilteredItems = filteredItemsCount
- };
-
- //
- return result;
- }
-
///
/// Remove Specified Webinar ...
///
@@ -971,10 +908,16 @@ namespace xWebinarService.Providers
try
{
//
- var medias = await WebinarFileProvider.GetAllFor(entity.Id);
+ var medias = await WebinarFileProvider.GetAllReferences(entity.Id);
if (!medias.IsNull() && medias.HasChild())
{
- await RemoveFiles(entity.Id, string.Empty, userInfo);
+ //
+ await RemoveFiles(
+ id: entity.Id,
+ ids: string.Empty,
+ userInfo: userInfo,
+ connectionId: connectionId
+ );
}
}
catch { }
@@ -1005,11 +948,13 @@ namespace xWebinarService.Providers
///
///
///
+ ///
///
public async Task Subscribe(
Guid webinarId,
string subscriberId,
- string connectionId = null
+ string connectionId = null,
+ XUserClaimsInfoDto userInfo = null
)
{
//
@@ -1020,10 +965,11 @@ namespace xWebinarService.Providers
result =
!webinarId.IsNull() &&
!webinarId.IsDefaultGuid() &&
- !subscriberId.IsNullOrEmpty();
+ !subscriberId.IsNullOrEmpty() &&
+ !userInfo.IsNullOrDefault();
if (!result)
{
- return result;
+ XException.InvalidArgs.Throw();
}
//
@@ -1031,38 +977,46 @@ namespace xWebinarService.Providers
result = await WebinarRepository.IsExistsAsync(webinarId);
if (!result)
{
- return result;
+ XException.NotFound.Throw();
}
//
// Retrieve Webinar Entity ...
var webinar = await WebinarRepository.GetAsync(webinarId);
-
- //
- // Check Webinar Enabled ...
- result = webinar.Enabled;
+ result = !webinar.IsNullOrDefault();
if (!result)
{
- return result;
+ XException.ActionFailed.Throw();
+ }
+
+ //
+ // Check Permissions ...
+ result =
+ userInfo.UserId == webinar.OwnerId ||
+ webinar.Type == XWebinarType.Public ||
+ userInfo.Roles.Any(r => r.ToNormalString() == "admin");
+ if (!result)
+ {
+ XException.NotAllowed.Throw();
}
//
// Check User Exists ...
var device = IdentityProvider.GetDevice();
- XOpenActionUserInfoDto userInfo = null;
+ XOpenActionUserInfoDto subscriber = null;
try
{
//
- userInfo = await IdentityProvider.GetUserInfo(
+ subscriber = await IdentityProvider.GetUserInfo(
device: device,
userSelectByParam: subscriberId
);
}
catch { }
- result = !userInfo.IsNullOrDefault();
+ result = !subscriber.IsNullOrDefault();
if (!result)
{
- return result;
+ XException.NotFound.Throw();
}
//
@@ -1094,10 +1048,12 @@ namespace xWebinarService.Providers
///
///
///
+ ///
///
public async Task IsSubscribed(
Guid webinarId,
- string subscriberId
+ string subscriberId,
+ XUserClaimsInfoDto userInfo = null
)
{
//
@@ -1108,37 +1064,50 @@ namespace xWebinarService.Providers
result =
!webinarId.IsNull() &&
!webinarId.IsDefaultGuid() &&
+ !userInfo.IsNullOrDefault() &&
!subscriberId.IsNullOrEmpty();
if (!result)
{
- return result;
+ XException.InvalidArgs.Throw();
}
//
// Check Webinar Exists ...
- result = await WebinarRepository.IsExistsAsync(webinarId);
+ var webinar = await WebinarRepository.GetAsync(webinarId);
+ result = !webinar.IsNullOrDefault();
if (!result)
{
- return result;
+ XException.NotFound.Throw();
+ }
+
+ //
+ // Check Permission ...
+ result =
+ userInfo.UserId == subscriberId ||
+ userInfo.UserId == webinar.OwnerId ||
+ userInfo.Roles.Any(r => r.ToNormalString() == "admin");
+ if (!result)
+ {
+ XException.NotAllowed.Throw();
}
//
// Check User Exists ...
var device = IdentityProvider.GetDevice();
- XOpenActionUserInfoDto userInfo = null;
+ XOpenActionUserInfoDto suscriber = null;
try
{
//
- userInfo = await IdentityProvider.GetUserInfo(
+ suscriber = await IdentityProvider.GetUserInfo(
device: device,
userSelectByParam: subscriberId
);
}
catch { }
- result = !userInfo.IsNullOrDefault();
+ result = !suscriber.IsNullOrDefault();
if (!result)
{
- return result;
+ XException.NotFound.Throw();
}
//
@@ -1157,11 +1126,13 @@ namespace xWebinarService.Providers
///
///
///
+ ///
///
public async Task Unsubscribe(
Guid webinarId,
string subscriberId,
- string connectionId = null
+ string connectionId = null,
+ XUserClaimsInfoDto userInfo = null
)
{
//
@@ -1172,26 +1143,44 @@ namespace xWebinarService.Providers
result =
!webinarId.IsNull() &&
!webinarId.IsDefaultGuid() &&
+ !userInfo.IsNullOrDefault() &&
!subscriberId.IsNullOrEmpty();
if (!result)
{
- return result;
+ XException.InvalidArgs.Throw();
}
//
- // Check Subscription ..
+ // Check Subscription ...
result = await IsSubscribed(
webinarId: webinarId,
+ userInfo: userInfo,
subscriberId: subscriberId
);
if (!result)
{
- return result;
+ XException.NotFound.Throw();
}
//
// Retrieve Webinar ...
var webinar = await WebinarRepository.GetAsync(webinarId);
+ result = !webinar.IsNullOrDefault();
+ if (!result)
+ {
+ XException.ActionFailed.Throw();
+ }
+
+ //
+ // Check Permissions ...
+ result =
+ userInfo.UserId == subscriberId ||
+ userInfo.UserId == webinar.OwnerId ||
+ userInfo.Roles.Any(r => r.ToNormalString() == "admin");
+ if (!result)
+ {
+ XException.NotAllowed.Throw();
+ }
//
// Retrieve Subscription Entity ...
@@ -1220,10 +1209,12 @@ namespace xWebinarService.Providers
///
///
///
+ ///
///
public async Task GetSubscriber(
Guid webinarId,
- string subscriberId
+ string subscriberId,
+ XUserClaimsInfoDto userInfo = null
)
{
//
@@ -1246,6 +1237,17 @@ namespace xWebinarService.Providers
XException.NotFound.Throw();
}
+ //
+ // Check Permissions ...
+ isValid =
+ userInfo.UserId == subscriberId ||
+ userInfo.UserId == webinar.OwnerId ||
+ userInfo.Roles.Any(r => r.ToNormalString() == "admin");
+ if (!isValid)
+ {
+ XException.NotAllowed.Throw();
+ }
+
//
// Retrieve Entity and Validate it ...
var entity = await WebinarSubscriberRepository.FindOneAsync(e =>
@@ -1268,15 +1270,18 @@ namespace xWebinarService.Providers
/// Get all Specified Webinars Subscribers ...
///
///
+ ///
///
public async Task> GetSubscribers(
- Guid webinarId
+ Guid webinarId,
+ XUserClaimsInfoDto userInfo = null
)
{
//
// Validate ...
bool isValid =
!webinarId.IsNull() &&
+ !userInfo.IsNullOrDefault() &&
!webinarId.IsDefaultGuid();
if (!isValid)
{
@@ -1292,6 +1297,21 @@ namespace xWebinarService.Providers
XException.NotFound.Throw();
}
+ //
+ // Check Permissions ...
+ isValid =
+ (await IsSubscribed(
+ userInfo: userInfo,
+ webinarId: webinarId,
+ subscriberId: userInfo.UserId
+ )) ||
+ userInfo.UserId == webinar.OwnerId ||
+ userInfo.Roles.Any(r => r.ToNormalString() == "admin");
+ if (!isValid)
+ {
+ XException.NotAllowed.Throw();
+ }
+
//
var subscribers = await WebinarSubscriberRepository.FindManyAsync(e =>
e.WebinarId == webinarId
@@ -1311,10 +1331,12 @@ namespace xWebinarService.Providers
///
///
///
+ ///
///
public async Task> QuerySubscribers(
Guid webinarId,
- XQuery query
+ XQuery query,
+ XUserClaimsInfoDto userInfo = null
)
{
//
@@ -1322,7 +1344,8 @@ namespace xWebinarService.Providers
bool isValid =
!query.IsNull() &&
!webinarId.IsNull() &&
- !webinarId.IsDefaultGuid();
+ !webinarId.IsDefaultGuid() &&
+ !userInfo.IsNullOrDefault();
if (!isValid)
{
XException.InvalidArgs.Throw();
@@ -1334,15 +1357,32 @@ namespace xWebinarService.Providers
//
// Check Webinar Exists ...
- isValid = await WebinarRepository.IsExistsAsync(webinarId);
+ var webinar = await WebinarRepository.GetAsync(webinarId);
+ isValid = !webinar.IsNullOrDefault();
if (!isValid)
{
XException.NotFound.Throw();
}
+ //
+ // Check Permissions ...
+ isValid =
+ (await IsSubscribed(
+ userInfo: userInfo,
+ webinarId: webinarId,
+ subscriberId: userInfo.UserId
+ )) ||
+ userInfo.UserId == webinar.OwnerId ||
+ userInfo.Roles.Any(r => r.ToNormalString() == "admin");
+ if (!isValid)
+ {
+ XException.NotAllowed.Throw();
+ }
+
//
// Retrieve all Items ...
var items = await GetSubscribers(
+ userInfo: userInfo,
webinarId: webinarId
);
var totalItemsCount = items.Count();
@@ -1488,7 +1528,7 @@ namespace xWebinarService.Providers
}
//
- var result = await WebinarFileProvider.Remove(
+ var result = await WebinarFileProvider.RemoveFiles(
forProvidedId: id,
ids: ids,
userInfo: userInfo,
@@ -1501,22 +1541,38 @@ namespace xWebinarService.Providers
/// Get Webinar Files ...
///
///
+ ///
///
- public async Task> GetFiles(Guid id)
+ public async Task> GetFiles(
+ Guid id,
+ XUserClaimsInfoDto userInfo = null
+ )
{
//
- var result = new List();
+ // Validate ...
+ var isValid =
+ !id.IsNull() &&
+ !id.IsDefaultGuid() &&
+ !userInfo.IsNullOrDefault();
+ if (!isValid)
+ {
+ XException.InvalidArgs.Throw();
+ }
//
- var dto = await GetWebinar(id);
- if (!dto.IsNullOrDefault())
+ // Check Webinar Exists ...
+ var webinar = await WebinarRepository.GetAsync(id);
+ isValid = !webinar.IsNullOrDefault();
+ if (!isValid)
{
- //
- result = (await WebinarFileProvider
- .GetAllFor(id))
- .ToList();
+ XException.NotFound.Throw();
}
+ //
+ var result = (await WebinarFileProvider
+ .GetAllReferences(id))
+ .ToList();
+
//
return result;
}
@@ -1543,17 +1599,6 @@ namespace xWebinarService.Providers
XException.InvalidArgs.Throw();
}
- //
- // Check Specified File is Refrenced to Specified Webinar ...
- var files = await WebinarFileProvider.GetAllFor(id);
- isValid = !files.IsNull() &&
- files.HasChild() &&
- files.Any(f => f.Id == fileId);
- if (!isValid)
- {
- XException.NotFound.Throw();
- }
-
//
var result = await WebinarFileProvider.Stream(fileId);
return result;
@@ -1581,21 +1626,10 @@ namespace xWebinarService.Providers
XException.InvalidArgs.Throw();
}
- //
- // Check Specified File is Refrenced to Specified Webinar ...
- var files = await WebinarFileProvider.GetAllFor(id);
- isValid = !files.IsNull() &&
- files.HasChild() &&
- files.Any(f => f.Id == fileId);
- if (!isValid)
- {
- XException.NotFound.Throw();
- }
-
//
var result = await WebinarFileProvider.Download(fileId);
return result;
- }
+ }
#endregion
//
@@ -1623,50 +1657,57 @@ namespace xWebinarService.Providers
!id.IsNull() &&
!id.IsDefaultGuid() &&
!userInfo.IsNullOrDefault();
- if (isValid)
+ if (!isValid)
+ {
+ XException.InvalidArgs.Throw();
+ }
+
+ //
+ // Check Permissions ...
+ isValid = await HasPermission(
+ id: id,
+ userInfo: userInfo
+ );
+ if (!isValid)
+ {
+ XException.NotAllowed.Throw();
+ }
+
+ //
+ try
{
//
- // Check Permissions ...
- isValid = await HasPermission(
- id: id,
- userInfo: userInfo
+ // Attached Tag to Webinar ...
+ await WebinarTagProvider.AddReference(
+ tag: tag,
+ forIndex: 0,
+ providedForId: id,
+ connectionId: connectionId
);
- if (!isValid)
- {
- XException.NotAllowed.Throw();
- }
//
- try
+ if (forceAttachToFiles)
{
//
- // Attached Tag to Webinar ...
- await WebinarTagProvider.Attach(tag, id, connectionId);
-
- //
- if (forceAttachToFiles)
+ var medias = await WebinarFileProvider.GetAllReferences(id);
+ isValid = !medias.IsNull() && medias.HasChild();
+ if (isValid)
{
//
- var medias = await WebinarFileProvider.GetAllFor(id);
- isValid = !medias.IsNull() && medias.HasChild();
- if (isValid)
+ foreach (var media in medias)
{
//
- foreach (var media in medias)
- {
- //
- await WebinarFileProvider.Provider.AttachTag(
- id: media.Id,
- tag: tag,
- userInfo: userInfo,
- connectionId: connectionId
- );
- }
+ await WebinarFileProvider.FileProvider.AttachTag(
+ tag: tag,
+ id: media.Id,
+ userInfo: userInfo,
+ connectionId: connectionId
+ );
}
}
}
- catch { }
}
+ catch { }
}
///
@@ -1691,49 +1732,56 @@ namespace xWebinarService.Providers
var isValid = !tag.IsNullOrEmpty() &&
!id.IsNull() &&
!id.IsDefaultGuid();
- if (isValid)
+ if (!isValid)
+ {
+ XException.InvalidArgs.Throw();
+ }
+
+ //
+ // Check Permissions ...
+ isValid = await HasPermission(
+ id: id,
+ userInfo: userInfo
+ );
+ if (!isValid)
+ {
+ XException.NotAllowed.Throw();
+ }
+
+ //
+ try
{
//
- // Check Permissions ...
- isValid = await HasPermission(
- id: id,
- userInfo: userInfo
- );
- if (!isValid)
- {
- XException.NotAllowed.Throw();
- }
+ await WebinarTagProvider
+ .RemoveReference(
+ tag: tag,
+ providedForId: id,
+ connectionId: connectionId
+ );
//
- try
+ if (forceDetachFromFiles)
{
//
- await WebinarTagProvider.Detach(tag, id, connectionId);
-
- //
- if (forceDetachFromFiles)
+ var medias = await WebinarFileProvider.GetAllReferences(id);
+ isValid = !medias.IsNull() && medias.HasChild();
+ if (isValid)
{
//
- var medias = await WebinarFileProvider.GetAllFor(id);
- isValid = !medias.IsNull() && medias.HasChild();
- if (isValid)
+ foreach (var media in medias)
{
//
- foreach (var media in medias)
- {
- //
- await WebinarFileProvider.Provider.DetachTag(
- id: media.Id,
- tag: tag,
- userInfo: userInfo,
- connectionId: connectionId
- );
- }
+ await WebinarFileProvider.FileProvider.DetachTag(
+ tag: tag,
+ id: media.Id,
+ userInfo: userInfo,
+ connectionId: connectionId
+ );
}
}
}
- catch { }
}
+ catch { }
}
///
@@ -1759,37 +1807,39 @@ namespace xWebinarService.Providers
tags.HasChild() &&
!id.IsNull() &&
!id.IsDefaultGuid();
- if (isValid)
+ if (!isValid)
+ {
+ XException.InvalidArgs.Throw();
+ }
+
+ //
+ // Check Permissions ...
+ isValid = await HasPermission(
+ id: id,
+ userInfo: userInfo
+ );
+ if (!isValid)
+ {
+ XException.NotAllowed.Throw();
+ }
+
+ //
+ try
{
//
- // Check Permissions ...
- isValid = await HasPermission(
- id: id,
- userInfo: userInfo
- );
- if (!isValid)
- {
- XException.NotAllowed.Throw();
- }
-
- //
- try
+ foreach (var tag in tags)
{
//
- foreach (var tag in tags)
- {
- //
- await AttachTag(
- tag,
- id,
- userInfo,
- connectionId,
- forceAttachToFiles
- );
- }
+ await AttachTag(
+ id: id,
+ tag: tag,
+ userInfo: userInfo,
+ connectionId: connectionId,
+ forceAttachToFiles: forceAttachToFiles
+ );
}
- catch { }
}
+ catch { }
}
///
@@ -1815,43 +1865,46 @@ namespace xWebinarService.Providers
tags.HasChild() &&
!id.IsNull() &&
!id.IsDefaultGuid();
- if (isValid)
+ if (!isValid)
+ {
+ XException.InvalidArgs.Throw();
+ }
+
+ //
+ // Check Permissions ...
+ isValid = await HasPermission(
+ id: id,
+ userInfo: userInfo
+ );
+ if (!isValid)
+ {
+ XException.NotAllowed.Throw();
+ }
+
+ //
+ try
{
//
- // Check Permissions ...
- isValid = await HasPermission(
- id: id,
- userInfo: userInfo
- );
- if (!isValid)
- {
- XException.NotAllowed.Throw();
- }
-
- //
- try
+ foreach (var tag in tags)
{
//
- foreach (var tag in tags)
- {
- //
- await DetachTag(
- tag,
- id,
- userInfo,
- connectionId,
- forceDetachFromFiles
- );
- }
+ await DetachTag(
+ id: id,
+ tag: tag,
+ userInfo: userInfo,
+ connectionId: connectionId,
+ forceDetachFromFiles: forceDetachFromFiles
+ );
}
- catch { }
}
+ catch { }
}
///
- /// Detach all Attached Tags for Specified File ...
+ /// Detach all Attached Tags for Specified Webinar ...
///
///
+ ///
///
///
///
@@ -1865,47 +1918,52 @@ namespace xWebinarService.Providers
//
// Validate ...
var isValid = !id.IsNull() && !id.IsDefaultGuid();
- if (isValid)
+ if (!isValid)
+ {
+ XException.InvalidArgs.Throw();
+ }
+
+ //
+ // Check Permissions ...
+ isValid = await HasPermission(
+ id: id,
+ userInfo: userInfo
+ );
+ if (!isValid)
+ {
+ XException.NotAllowed.Throw();
+ }
+
+ //
+ try
{
//
- // Check Permissions ...
- isValid = await HasPermission(
- id: id,
- userInfo: userInfo
+ await WebinarTagProvider.RemoveReferences(
+ providedForId: id,
+ connectionId: connectionId
);
- if (!isValid)
- {
- XException.NotAllowed.Throw();
- }
//
- try
+ if (forceDetachFromFiles)
{
//
- var tags = await WebinarTagProvider.RemoveTagsFor(id, connectionId);
-
- //
- if (forceDetachFromFiles)
+ var medias = await WebinarFileProvider.GetAllReferences(id);
+ isValid = !medias.IsNull() && medias.HasChild();
+ if (isValid)
{
//
- var medias = await WebinarFileProvider.GetAllFor(id);
- if (!medias.IsNull() && medias.HasChild())
+ foreach (var media in medias)
{
//
- foreach (var media in medias)
- {
- //
- await WebinarFileProvider.Provider.DetachTags(
- id: media.Id,
- userInfo: userInfo,
- connectionId: connectionId
- );
- }
+ await WebinarFileProvider.FileProvider.TagProvider.RemoveReferences(
+ providedForId: media.Id,
+ connectionId: connectionId
+ );
}
}
}
- catch { }
}
+ catch { }
}
///
@@ -1930,19 +1988,32 @@ namespace xWebinarService.Providers
}
//
- // Checking Permissions ...
-
- //
- // Checking Exists ...
- isValid = await WebinarRepository.IsExistsAsync(id);
+ // Check Webinar Wxists ...
+ var webinar = await WebinarRepository.GetAsync(id);
+ isValid = !webinar.IsNullOrDefault();
if (!isValid)
{
XException.NotFound.Throw();
}
+ //
+ // Checking Permissions ...
+ isValid =
+ (await IsSubscribed(
+ webinarId: id,
+ userInfo: userInfo,
+ subscriberId: userInfo.UserId
+ )) ||
+ userInfo.UserId == webinar.OwnerId ||
+ userInfo.Roles.Any(r => r.ToNormalString() == "admin");
+ if (!isValid)
+ {
+ XException.NotAllowed.Throw();
+ }
+
//
// Reading Tags Dto List ...
- var tagsDtos = await WebinarTagProvider.GetTags(id);
+ var tagsDtos = await WebinarTagProvider.GetAllReferences(id);
//
var result = new List();
diff --git a/Providers/XWebinarTagProvider.cs b/Providers/XWebinarTagProvider.cs
index 87cad23..c7e930e 100644
--- a/Providers/XWebinarTagProvider.cs
+++ b/Providers/XWebinarTagProvider.cs
@@ -11,8 +11,8 @@ namespace xWebinarService.Providers
public XWebinarTagProvider(
IXTagProvider tagProvider
) : base(
- nameof(XWebinar),
- tagProvider
+ providedFor: nameof(XWebinar),
+ tagProvider: tagProvider
)
{ }
}