last ...
This commit is contained in:
@@ -57,13 +57,6 @@ namespace xWebinarService.Controllers
|
||||
/// <param name="tags"></param>
|
||||
/// <param name="files"></param>
|
||||
/// <returns></returns>
|
||||
/// <summary>
|
||||
/// Create Webinar ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="tags"></param>
|
||||
/// <param name="files"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("")]
|
||||
public virtual async Task<ActionResult<XWebinarDto>> CreateWebinar(
|
||||
[FromForm] XWebinarDto item,
|
||||
|
||||
@@ -89,12 +89,6 @@ namespace xWebinarService.Interfaces
|
||||
/// <returns></returns>
|
||||
Task<XWebinarDto> GetWebinar(Guid id);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve all Exists Webinar Ids ...
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
IEnumerable<Guid> GetWebinarIds();
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve all Exists Webinars ...
|
||||
/// </summary>
|
||||
@@ -139,13 +133,6 @@ namespace xWebinarService.Interfaces
|
||||
XUserClaimsInfoDto userInfo = null
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Query Webinar Ids ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <returns></returns>
|
||||
XQueryResult<Guid> QueryWebinarIds(XQuery query);
|
||||
|
||||
/// <summary>
|
||||
/// Remove Specified Webinar ...
|
||||
/// </summary>
|
||||
@@ -168,11 +155,13 @@ namespace xWebinarService.Interfaces
|
||||
/// <param name="webinarId"></param>
|
||||
/// <param name="subscriberId"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> Subscribe(
|
||||
Guid webinarId,
|
||||
string subscriberId,
|
||||
string connectionId = null
|
||||
string connectionId = null,
|
||||
XUserClaimsInfoDto userInfo = null
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
@@ -180,10 +169,12 @@ namespace xWebinarService.Interfaces
|
||||
/// </summary>
|
||||
/// <param name="webinarId"></param>
|
||||
/// <param name="subscriberId"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> IsSubscribed(
|
||||
Guid webinarId,
|
||||
string subscriberId
|
||||
string subscriberId,
|
||||
XUserClaimsInfoDto userInfo = null
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
@@ -192,11 +183,13 @@ namespace xWebinarService.Interfaces
|
||||
/// <param name="webinarId"></param>
|
||||
/// <param name="subscriberId"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> Unsubscribe(
|
||||
Guid webinarId,
|
||||
string subscriberId,
|
||||
string connectionId = null
|
||||
string connectionId = null,
|
||||
XUserClaimsInfoDto userInfo = null
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
@@ -204,28 +197,36 @@ namespace xWebinarService.Interfaces
|
||||
/// </summary>
|
||||
/// <param name="webinarId"></param>
|
||||
/// <param name="subscriberId"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <returns></returns>
|
||||
Task<XWebinarSubscriberDto> GetSubscriber(
|
||||
Guid webinarId,
|
||||
string subscriberId
|
||||
string subscriberId,
|
||||
XUserClaimsInfoDto userInfo = null
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Get all Specified Webinars Subscribers ...
|
||||
/// </summary>
|
||||
/// <param name="webinarId"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<XWebinarSubscriberDto>> GetSubscribers(Guid webinarId);
|
||||
Task<IEnumerable<XWebinarSubscriberDto>> GetSubscribers(
|
||||
Guid webinarId,
|
||||
XUserClaimsInfoDto userInfo = null
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Query Specified Webinar's Subscribers ...
|
||||
/// </summary>
|
||||
/// <param name="webinarId"></param>
|
||||
/// <param name="query"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <returns></returns>
|
||||
Task<XQueryResult<XWebinarSubscriberDto>> QuerySubscribers(
|
||||
Guid webinarId,
|
||||
XQuery query
|
||||
XQuery query,
|
||||
XUserClaimsInfoDto userInfo = null
|
||||
);
|
||||
#endregion
|
||||
|
||||
@@ -265,8 +266,12 @@ namespace xWebinarService.Interfaces
|
||||
/// Get Webinar Files ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<XFileDto>> GetFiles(Guid id);
|
||||
Task<IEnumerable<XFileDto>> GetFiles(
|
||||
Guid id,
|
||||
XUserClaimsInfoDto userInfo = null
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Stream Specified File ...
|
||||
|
||||
@@ -9,10 +9,10 @@ namespace xWebinarService.Providers
|
||||
public class XWebinarFileProvider : XBaseFileProvider<Guid>, IXWebinarFileProvider
|
||||
{
|
||||
public XWebinarFileProvider(
|
||||
IXFileProvider provider
|
||||
IXFileProvider fileProvider
|
||||
) : base(
|
||||
providedFor: nameof(XWebinar),
|
||||
provider: provider
|
||||
fileProvider: fileProvider
|
||||
)
|
||||
{ }
|
||||
}
|
||||
|
||||
+359
-288
@@ -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<IEnumerable<XWebinarDto>> GetWebinars()
|
||||
{
|
||||
//
|
||||
var list = await WebinarRepository.GetAllAsync();
|
||||
var result = await list.SelectAsync(async l => await ToXWebinarDto(l));
|
||||
var entities = WebinarRepository
|
||||
.AsQueryable()
|
||||
.ToList();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve all Exists Webinar Ids ...
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<Guid> GetWebinarIds()
|
||||
{
|
||||
//
|
||||
var result = WebinarRepository.AsQueryable().Select(l => l.Id);
|
||||
//
|
||||
var result = new List<XWebinarDto>();
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Query Webinar Ids ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <returns></returns>
|
||||
public XQueryResult<Guid> 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<Guid>
|
||||
{
|
||||
Items = items,
|
||||
Page = query.Page,
|
||||
PageSize = query.PageSize,
|
||||
TotalPages = totalPagesCount,
|
||||
TotalItems = totalItemsCount,
|
||||
TotalFilteredPages = filteredPagesCount,
|
||||
TotalFilteredItems = filteredItemsCount
|
||||
};
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove Specified Webinar ...
|
||||
/// </summary>
|
||||
@@ -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
|
||||
/// <param name="webinarId"></param>
|
||||
/// <param name="subscriberId"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> 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
|
||||
/// </summary>
|
||||
/// <param name="webinarId"></param>
|
||||
/// <param name="subscriberId"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> 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
|
||||
/// <param name="webinarId"></param>
|
||||
/// <param name="subscriberId"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> 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
|
||||
/// </summary>
|
||||
/// <param name="webinarId"></param>
|
||||
/// <param name="subscriberId"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<XWebinarSubscriberDto> 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 ...
|
||||
/// </summary>
|
||||
/// <param name="webinarId"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IEnumerable<XWebinarSubscriberDto>> 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
|
||||
/// </summary>
|
||||
/// <param name="webinarId"></param>
|
||||
/// <param name="query"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<XQueryResult<XWebinarSubscriberDto>> 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 ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IEnumerable<XFileDto>> GetFiles(Guid id)
|
||||
public async Task<IEnumerable<XFileDto>> GetFiles(
|
||||
Guid id,
|
||||
XUserClaimsInfoDto userInfo = null
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = new List<XFileDto>();
|
||||
// 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 { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -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 { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -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 { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -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 { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Detach all Attached Tags for Specified File ...
|
||||
/// 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>
|
||||
@@ -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 { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -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<string>();
|
||||
|
||||
@@ -11,8 +11,8 @@ namespace xWebinarService.Providers
|
||||
public XWebinarTagProvider(
|
||||
IXTagProvider tagProvider
|
||||
) : base(
|
||||
nameof(XWebinar),
|
||||
tagProvider
|
||||
providedFor: nameof(XWebinar),
|
||||
tagProvider: tagProvider
|
||||
)
|
||||
{ }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user