Add support of Tag and File Provider to Webinar Provider ...
required to Implement Uploading ...
This commit is contained in:
@@ -4,6 +4,8 @@ using xCommons.Extensions;
|
|||||||
using xDataService.Interfaces;
|
using xDataService.Interfaces;
|
||||||
using xDataService.Providers;
|
using xDataService.Providers;
|
||||||
using xExceptions.Constants;
|
using xExceptions.Constants;
|
||||||
|
using xFileService.Interfaces;
|
||||||
|
using xTagService.Interfaces;
|
||||||
using xWebinarService.Interfaces;
|
using xWebinarService.Interfaces;
|
||||||
using xWebinarService.Interfaces.Entities;
|
using xWebinarService.Interfaces.Entities;
|
||||||
using xWebinarService.Models.Entities;
|
using xWebinarService.Models.Entities;
|
||||||
@@ -83,11 +85,13 @@ namespace xWebinarService.DI
|
|||||||
// Check Dependencies Exists ...
|
// Check Dependencies Exists ...
|
||||||
var isDependenciesPassed = !services
|
var isDependenciesPassed = !services
|
||||||
.GetRegisteredService<IXWebinarSubscriberRepository>()
|
.GetRegisteredService<IXWebinarSubscriberRepository>()
|
||||||
.IsNull();
|
.IsNull() &&
|
||||||
|
!services.GetRegisteredService<IXTagProvider>().IsNull() &&
|
||||||
|
!services.GetRegisteredService<IXFileProvider>().IsNull();
|
||||||
if (!isDependenciesPassed)
|
if (!isDependenciesPassed)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
Log("AddFileService failed due Dependencies Issues, IXWebinarSubscriberRepository not provided ...");
|
Log("AddFileService failed due Dependencies Issues, IXTagProvider, IXFileProvider, IXWebinarSubscriberRepository not provided ...");
|
||||||
throw exception;
|
throw exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,6 +117,14 @@ namespace xWebinarService.DI
|
|||||||
services.Add(new ServiceDescriptor(typeof(IXWebinarTitleResourceProvider), typeof(XWebinarTitleResourceProvider), lifeTime));
|
services.Add(new ServiceDescriptor(typeof(IXWebinarTitleResourceProvider), typeof(XWebinarTitleResourceProvider), lifeTime));
|
||||||
services.Add(new ServiceDescriptor(typeof(IXWebinarDescriptionResourceProvider), typeof(XWebinarDescriptionResourceProvider), lifeTime));
|
services.Add(new ServiceDescriptor(typeof(IXWebinarDescriptionResourceProvider), typeof(XWebinarDescriptionResourceProvider), lifeTime));
|
||||||
|
|
||||||
|
//
|
||||||
|
// Register Webinar Tag Provider ...
|
||||||
|
services.Add(new ServiceDescriptor(typeof(IXWebinarTagProvider), typeof(XWebinarTagProvider), lifeTime));
|
||||||
|
|
||||||
|
//
|
||||||
|
// Register Webinar File Provider ...
|
||||||
|
services.Add(new ServiceDescriptor(typeof(IXWebinarFileProvider), typeof(XWebinarFileProvider), lifeTime));
|
||||||
|
|
||||||
//
|
//
|
||||||
// Register Main Provider ...
|
// Register Main Provider ...
|
||||||
services.Add(new ServiceDescriptor(typeof(IXWebinarProvider), typeof(XWebinarProvider), lifeTime));
|
services.Add(new ServiceDescriptor(typeof(IXWebinarProvider), typeof(XWebinarProvider), lifeTime));
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
using System;
|
||||||
|
using xFileService.Interfaces;
|
||||||
|
|
||||||
|
namespace xWebinarService.Interfaces
|
||||||
|
{
|
||||||
|
public interface IXWebinarFileProvider : IXBaseFileProvider<Guid>
|
||||||
|
{ }
|
||||||
|
}
|
||||||
@@ -19,6 +19,8 @@ namespace xWebinarService.Interfaces
|
|||||||
IHubContext<XWebinarEntityHub> Hub { get; }
|
IHubContext<XWebinarEntityHub> Hub { get; }
|
||||||
IXIdentityProvider IdentityProvider { get; }
|
IXIdentityProvider IdentityProvider { get; }
|
||||||
IXWebinarRepository WebinarRepository { get; }
|
IXWebinarRepository WebinarRepository { get; }
|
||||||
|
IXWebinarTagProvider WebinarTagProvider { get; }
|
||||||
|
IXWebinarFileProvider WebinarFileProvider { get; }
|
||||||
XDataServiceConfiguration DataSercviceConfiguration { get; }
|
XDataServiceConfiguration DataSercviceConfiguration { get; }
|
||||||
IXWebinarTitleResourceProvider TitleResourceProvider { get; }
|
IXWebinarTitleResourceProvider TitleResourceProvider { get; }
|
||||||
IXWebinarSubscriberRepository WebinarSubscriberRepository { get; }
|
IXWebinarSubscriberRepository WebinarSubscriberRepository { get; }
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
using System;
|
||||||
|
using xTagService.Interfaces;
|
||||||
|
|
||||||
|
namespace xWebinarService.Interfaces
|
||||||
|
{
|
||||||
|
public interface IXWebinarTagProvider : IXBaseTagProvider<Guid>
|
||||||
|
{ }
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
using xFileService.Interfaces;
|
||||||
|
using xFileService.Providers;
|
||||||
|
using xWebinarService.Interfaces;
|
||||||
|
using xWebinarService.Models.Entities;
|
||||||
|
|
||||||
|
namespace xWebinarService.Providers
|
||||||
|
{
|
||||||
|
public class XWebinarFileProvider : XBaseFileProvider<Guid>, IXWebinarFileProvider
|
||||||
|
{
|
||||||
|
public XWebinarFileProvider(
|
||||||
|
IXFileProvider provider
|
||||||
|
) : base(
|
||||||
|
providedFor: nameof(XWebinar),
|
||||||
|
provider: provider
|
||||||
|
)
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,12 +2,14 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.SignalR;
|
using Microsoft.AspNetCore.SignalR;
|
||||||
using xCommons.Extensions;
|
using xCommons.Extensions;
|
||||||
using xDataService.Configuration;
|
using xDataService.Configuration;
|
||||||
using xDataService.Extensions;
|
using xDataService.Extensions;
|
||||||
using xExceptions.Constants;
|
using xExceptions.Constants;
|
||||||
using xIdentityModels.Dtos;
|
using xIdentityModels.Dtos;
|
||||||
|
using xIdentityModels.Models;
|
||||||
using xIdentityService.Extensions;
|
using xIdentityService.Extensions;
|
||||||
using xIdentityService.Interfaces;
|
using xIdentityService.Interfaces;
|
||||||
using xModels.Dtos;
|
using xModels.Dtos;
|
||||||
@@ -18,6 +20,7 @@ using xWebinarService.Interfaces;
|
|||||||
using xWebinarService.Interfaces.Entities;
|
using xWebinarService.Interfaces.Entities;
|
||||||
using xWebinarService.Models.Dtos;
|
using xWebinarService.Models.Dtos;
|
||||||
using xWebinarService.Models.Entities;
|
using xWebinarService.Models.Entities;
|
||||||
|
using XFileDto = xFileService.Models.Dtos.XFileDto;
|
||||||
|
|
||||||
namespace xWebinarService.Providers
|
namespace xWebinarService.Providers
|
||||||
{
|
{
|
||||||
@@ -31,6 +34,8 @@ namespace xWebinarService.Providers
|
|||||||
public IHubContext<XWebinarEntityHub> Hub { get; }
|
public IHubContext<XWebinarEntityHub> Hub { get; }
|
||||||
public IXIdentityProvider IdentityProvider { get; }
|
public IXIdentityProvider IdentityProvider { get; }
|
||||||
public IXWebinarRepository WebinarRepository { get; }
|
public IXWebinarRepository WebinarRepository { get; }
|
||||||
|
public IXWebinarTagProvider WebinarTagProvider { get; }
|
||||||
|
public IXWebinarFileProvider WebinarFileProvider { get; }
|
||||||
public XDataServiceConfiguration DataSercviceConfiguration { get; }
|
public XDataServiceConfiguration DataSercviceConfiguration { get; }
|
||||||
public IXWebinarTitleResourceProvider TitleResourceProvider { get; }
|
public IXWebinarTitleResourceProvider TitleResourceProvider { get; }
|
||||||
public IXWebinarSubscriberRepository WebinarSubscriberRepository { get; }
|
public IXWebinarSubscriberRepository WebinarSubscriberRepository { get; }
|
||||||
@@ -42,6 +47,8 @@ namespace xWebinarService.Providers
|
|||||||
public XWebinarProvider(
|
public XWebinarProvider(
|
||||||
IXIdentityProvider identityProvider,
|
IXIdentityProvider identityProvider,
|
||||||
IXWebinarRepository webinarRepository,
|
IXWebinarRepository webinarRepository,
|
||||||
|
IXWebinarTagProvider webinarTagProvider,
|
||||||
|
IXWebinarFileProvider webinarFileProvider,
|
||||||
XDataServiceConfiguration dataSercviceConfiguration,
|
XDataServiceConfiguration dataSercviceConfiguration,
|
||||||
IXWebinarTitleResourceProvider titleResourceProvider,
|
IXWebinarTitleResourceProvider titleResourceProvider,
|
||||||
IXWebinarSubscriberRepository webinarSubscriberRepository,
|
IXWebinarSubscriberRepository webinarSubscriberRepository,
|
||||||
@@ -50,13 +57,15 @@ namespace xWebinarService.Providers
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
Hub = hub;
|
||||||
IdentityProvider = identityProvider;
|
IdentityProvider = identityProvider;
|
||||||
WebinarRepository = webinarRepository;
|
WebinarRepository = webinarRepository;
|
||||||
DataSercviceConfiguration = dataSercviceConfiguration;
|
WebinarTagProvider = webinarTagProvider;
|
||||||
|
WebinarFileProvider = webinarFileProvider;
|
||||||
TitleResourceProvider = titleResourceProvider;
|
TitleResourceProvider = titleResourceProvider;
|
||||||
|
DataSercviceConfiguration = dataSercviceConfiguration;
|
||||||
WebinarSubscriberRepository = webinarSubscriberRepository;
|
WebinarSubscriberRepository = webinarSubscriberRepository;
|
||||||
DescriptionResourceProvider = descriptionResourceProvider;
|
DescriptionResourceProvider = descriptionResourceProvider;
|
||||||
Hub = hub;
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -1143,6 +1152,347 @@ namespace xWebinarService.Providers
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
//
|
||||||
|
#region File Actions ...
|
||||||
|
/// <summary>
|
||||||
|
/// Upload Files ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="forProvidedId"></param>
|
||||||
|
/// <param name="files"></param>
|
||||||
|
/// <param name="userInfo"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<IEnumerable<XFileDto>> Upload(
|
||||||
|
Guid id,
|
||||||
|
IFormFileCollection files,
|
||||||
|
XUserClaimsInfoDto userInfo = null
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
var isValid = !id.IsNull() &&
|
||||||
|
!id.IsDefaultGuid() &&
|
||||||
|
!userInfo.IsNullOrDefault();
|
||||||
|
if (!isValid)
|
||||||
|
{
|
||||||
|
XException.InvalidArgs.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Permission ...
|
||||||
|
isValid = await HasPermission(id, userInfo);
|
||||||
|
if (!isValid)
|
||||||
|
{
|
||||||
|
XException.NotAllowed.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
var result = new List<XFileDto>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result = (await WebinarFileProvider.Upload(
|
||||||
|
files: files,
|
||||||
|
forProvidedId: id,
|
||||||
|
userInfo: userInfo
|
||||||
|
))
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get Webinar Files ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<IEnumerable<XFileDto>> GetFiles(Guid id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = new List<XFileDto>();
|
||||||
|
|
||||||
|
//
|
||||||
|
var dto = await GetWebinar(id);
|
||||||
|
if (!dto.IsNullOrDefault())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result = (await WebinarFileProvider
|
||||||
|
.GetAllFor(id))
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
//
|
||||||
|
#region Tags Actions ...
|
||||||
|
/// <summary>
|
||||||
|
/// Attach Tag to Specified File ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="tag"></param>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <param name="userInfo"></param>
|
||||||
|
/// <param name="forceAttachToFiles"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task TagAttach(
|
||||||
|
string tag,
|
||||||
|
Guid id,
|
||||||
|
XUserClaimsInfoDto userInfo = null,
|
||||||
|
bool forceAttachToFiles = true
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
var isValid = !tag.IsNullOrEmpty() &&
|
||||||
|
!id.IsNull() &&
|
||||||
|
!id.IsDefaultGuid() &&
|
||||||
|
!userInfo.IsNullOrDefault();
|
||||||
|
if (isValid)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Check Permissions ...
|
||||||
|
isValid = await HasPermission(
|
||||||
|
id: id,
|
||||||
|
userInfo: userInfo
|
||||||
|
);
|
||||||
|
if (!isValid)
|
||||||
|
{
|
||||||
|
XException.NotAllowed.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Attached Tag to Webinar ...
|
||||||
|
await WebinarTagProvider.Attach(tag, id);
|
||||||
|
|
||||||
|
//
|
||||||
|
if (forceAttachToFiles)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var medias = await WebinarFileProvider.GetAllFor(id);
|
||||||
|
isValid = !medias.IsNull() && medias.HasChild();
|
||||||
|
if (isValid)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
foreach (var media in medias)
|
||||||
|
{
|
||||||
|
await WebinarFileProvider.Provider.TagAttach(tag, media.Id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Detach Tag fro Specified File ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="tag"></param>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <param name="userInfo"></param>
|
||||||
|
/// <param name="forceAttachToFiles"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task TagDetach(
|
||||||
|
string tag,
|
||||||
|
Guid id,
|
||||||
|
XUserClaimsInfoDto userInfo = null,
|
||||||
|
bool forceDetachFromFiles = true
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
var isValid = !tag.IsNullOrEmpty() &&
|
||||||
|
!id.IsNull() &&
|
||||||
|
!id.IsDefaultGuid();
|
||||||
|
if (isValid)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Check Permissions ...
|
||||||
|
isValid = await HasPermission(
|
||||||
|
id: id,
|
||||||
|
userInfo: userInfo
|
||||||
|
);
|
||||||
|
if (!isValid)
|
||||||
|
{
|
||||||
|
XException.NotAllowed.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//
|
||||||
|
await WebinarTagProvider.Detach(tag, id);
|
||||||
|
|
||||||
|
//
|
||||||
|
if (forceDetachFromFiles)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var medias = await WebinarFileProvider.GetAllFor(id);
|
||||||
|
isValid = !medias.IsNull() && medias.HasChild();
|
||||||
|
if (isValid)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
foreach (var media in medias)
|
||||||
|
{
|
||||||
|
await WebinarFileProvider.Provider.TagDetach(tag, media.Id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Attach Tags for Specified File ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="tags"></param>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <param name="userInfo"></param>
|
||||||
|
/// <param name="forceAttachToFiles"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task TagsAttach(
|
||||||
|
IEnumerable<string> tags,
|
||||||
|
Guid id,
|
||||||
|
XUserClaimsInfoDto userInfo = null,
|
||||||
|
bool forceAttachToFiles = true
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
var isValid = !tags.IsNull() &&
|
||||||
|
tags.HasChild() &&
|
||||||
|
!id.IsNull() &&
|
||||||
|
!id.IsDefaultGuid();
|
||||||
|
if (isValid)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Check Permissions ...
|
||||||
|
isValid = await HasPermission(
|
||||||
|
id: id,
|
||||||
|
userInfo: userInfo
|
||||||
|
);
|
||||||
|
if (!isValid)
|
||||||
|
{
|
||||||
|
XException.NotAllowed.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//
|
||||||
|
foreach (var tag in tags)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
await TagAttach(
|
||||||
|
tag,
|
||||||
|
id,
|
||||||
|
userInfo,
|
||||||
|
forceAttachToFiles
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Detach Tags for Specified File ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="tags"></param>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <param name="userInfo"></param>
|
||||||
|
/// <param name="forceDetachFromFiles"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task TagsDetach(
|
||||||
|
IEnumerable<string> tags,
|
||||||
|
Guid id,
|
||||||
|
XUserClaimsInfoDto userInfo = null,
|
||||||
|
bool forceDetachFromFiles = true
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
var isValid = !tags.IsNull() &&
|
||||||
|
tags.HasChild() &&
|
||||||
|
!id.IsNull() &&
|
||||||
|
!id.IsDefaultGuid();
|
||||||
|
if (isValid)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Check Permissions ...
|
||||||
|
isValid = await HasPermission(
|
||||||
|
id: id,
|
||||||
|
userInfo: userInfo
|
||||||
|
);
|
||||||
|
if (!isValid)
|
||||||
|
{
|
||||||
|
XException.NotAllowed.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//
|
||||||
|
foreach (var tag in tags)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
await TagDetach(
|
||||||
|
tag,
|
||||||
|
id,
|
||||||
|
userInfo,
|
||||||
|
forceDetachFromFiles
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Detach all Attached Tags for Specified File ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task TagsDetach(
|
||||||
|
Guid id,
|
||||||
|
XUserClaimsInfoDto userInfo = null
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
var isValid = !id.IsNull() && !id.IsDefaultGuid();
|
||||||
|
if (isValid)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Check Permissions ...
|
||||||
|
isValid = await HasPermission(
|
||||||
|
id: id,
|
||||||
|
userInfo: userInfo
|
||||||
|
);
|
||||||
|
if (!isValid)
|
||||||
|
{
|
||||||
|
XException.NotAllowed.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var tags = await WebinarTagProvider.RemoveTagsFor(id);
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
//
|
//
|
||||||
#region Hub Actions ...
|
#region Hub Actions ...
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -1196,5 +1546,50 @@ namespace xWebinarService.Providers
|
|||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
//
|
||||||
|
#region Private ...
|
||||||
|
/// <summary>
|
||||||
|
/// Check Specified User Info Has Permissions for Specified Webinar ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <param name="userInfo"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private async Task<bool> HasPermission(
|
||||||
|
Guid id,
|
||||||
|
XUserClaimsInfoDto userInfo = null
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
result = !id.IsNull() &&
|
||||||
|
!id.IsDefaultGuid() &&
|
||||||
|
!userInfo.IsNullOrDefault();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
XException.InvalidArgs.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Item Exists ...
|
||||||
|
var dto = await GetWebinar(id);
|
||||||
|
result = !dto.IsNullOrDefault();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
XException.NotFound.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
dto.OwnerId == userInfo.UserId ||
|
||||||
|
userInfo.Roles.Any(r => r.ToNormalString() == "admin");
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
using xTagService.Interfaces;
|
||||||
|
using xTagService.Providers;
|
||||||
|
using xWebinarService.Interfaces;
|
||||||
|
using xWebinarService.Models.Entities;
|
||||||
|
|
||||||
|
namespace xWebinarService.Providers
|
||||||
|
{
|
||||||
|
public class XWebinarTagProvider : XBaseTagProvider<Guid>, IXWebinarTagProvider
|
||||||
|
{
|
||||||
|
public XWebinarTagProvider(
|
||||||
|
IXTagProvider tagProvider
|
||||||
|
) : base(
|
||||||
|
nameof(XWebinar),
|
||||||
|
tagProvider
|
||||||
|
)
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -29,9 +29,11 @@
|
|||||||
|
|
||||||
<!-- Local Dependencies -->
|
<!-- Local Dependencies -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="../xTagService/xTagService.csproj" />
|
||||||
|
<ProjectReference Include="../xFileService/xFileService.csproj" />
|
||||||
<ProjectReference Include="../xPushService/xPushService.csproj" />
|
<ProjectReference Include="../xPushService/xPushService.csproj" />
|
||||||
<ProjectReference Include="../xIdentityService/xIdentityService.csproj" />
|
|
||||||
<ProjectReference Include="../xDataService/xDataService.csproj" />
|
<ProjectReference Include="../xDataService/xDataService.csproj" />
|
||||||
|
<ProjectReference Include="../xIdentityService/xIdentityService.csproj" />
|
||||||
<!--
|
<!--
|
||||||
<ProjectReference Include="../xStringService/xStringService.csproj" />
|
<ProjectReference Include="../xStringService/xStringService.csproj" />
|
||||||
-->
|
-->
|
||||||
|
|||||||
Reference in New Issue
Block a user