last implementation of webinar provider which required to test, builds ok ...
This commit is contained in:
@@ -1,14 +1,17 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.SignalR;
|
using Microsoft.AspNetCore.SignalR;
|
||||||
using xDataService.Configuration;
|
using xDataService.Configuration;
|
||||||
|
using xIdentityModels.Models;
|
||||||
using xIdentityService.Interfaces;
|
using xIdentityService.Interfaces;
|
||||||
using xModels.Dtos;
|
using xModels.Dtos;
|
||||||
using xWebinarService.Hubs;
|
using xWebinarService.Hubs;
|
||||||
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.Interfaces
|
namespace xWebinarService.Interfaces
|
||||||
{
|
{
|
||||||
@@ -51,10 +54,16 @@ namespace xWebinarService.Interfaces
|
|||||||
/// Create Webinar ...
|
/// Create Webinar ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item"></param>
|
/// <param name="item"></param>
|
||||||
|
/// <param name="tags"></param>
|
||||||
|
/// <param name="files"></param>
|
||||||
|
/// <param name="userInfo"></param>
|
||||||
/// <param name="connectionId"></param>
|
/// <param name="connectionId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<XWebinarDto> CreateWebinar(
|
Task<XWebinarDto> CreateWebinar(
|
||||||
XWebinarDto item,
|
XWebinarDto item,
|
||||||
|
IEnumerable<string> tags = null,
|
||||||
|
IFormFileCollection files = null,
|
||||||
|
XUserClaimsInfoDto userInfo = null,
|
||||||
string connectionId = null
|
string connectionId = null
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -62,10 +71,12 @@ namespace xWebinarService.Interfaces
|
|||||||
/// Update a Webinar ...
|
/// Update a Webinar ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item"></param>
|
/// <param name="item"></param>
|
||||||
|
/// <param name="userInfo"></param>
|
||||||
/// <param name="connectionId"></param>
|
/// <param name="connectionId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<XWebinarDto> UpdateWebinar(
|
Task<XWebinarDto> UpdateWebinar(
|
||||||
XWebinarDto item,
|
XWebinarDto item,
|
||||||
|
XUserClaimsInfoDto userInfo = null,
|
||||||
string connectionId = null
|
string connectionId = null
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -106,10 +117,12 @@ namespace xWebinarService.Interfaces
|
|||||||
/// Remove Specified Webinar ...
|
/// Remove Specified Webinar ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="webinarId"></param>
|
/// <param name="webinarId"></param>
|
||||||
|
/// <param name="userInfo"></param>
|
||||||
/// <param name="connectionId"></param>
|
/// <param name="connectionId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<bool> RemoveWebinar(
|
Task<bool> RemoveWebinar(
|
||||||
Guid webinarId,
|
Guid webinarId,
|
||||||
|
XUserClaimsInfoDto userInfo = null,
|
||||||
string connectionId = null
|
string connectionId = null
|
||||||
);
|
);
|
||||||
#endregion
|
#endregion
|
||||||
@@ -182,5 +195,114 @@ namespace xWebinarService.Interfaces
|
|||||||
XQuery query
|
XQuery query
|
||||||
);
|
);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
//
|
||||||
|
#region File Actions ...
|
||||||
|
/// <summary>
|
||||||
|
/// Upload Files ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="forProvidedId"></param>
|
||||||
|
/// <param name="files"></param>
|
||||||
|
/// <param name="userInfo"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<IEnumerable<XFileDto>> Upload(
|
||||||
|
Guid id,
|
||||||
|
IFormFileCollection files,
|
||||||
|
XUserClaimsInfoDto userInfo = null
|
||||||
|
);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove Specified Files ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="forProvidedId"></param>
|
||||||
|
/// <param name="ids"></param>
|
||||||
|
/// <param name="userInfo"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<IEnumerable<Guid>> RemoveFiles(
|
||||||
|
Guid id,
|
||||||
|
string ids = null,
|
||||||
|
XUserClaimsInfoDto userInfo = null
|
||||||
|
);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get Webinar Files ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<IEnumerable<XFileDto>> GetFiles(Guid id);
|
||||||
|
#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>
|
||||||
|
Task TagAttach(
|
||||||
|
string tag,
|
||||||
|
Guid id,
|
||||||
|
XUserClaimsInfoDto userInfo = null,
|
||||||
|
bool forceAttachToFiles = true
|
||||||
|
);
|
||||||
|
|
||||||
|
/// <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>
|
||||||
|
Task TagDetach(
|
||||||
|
string tag,
|
||||||
|
Guid id,
|
||||||
|
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="forceAttachToFiles"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task TagsAttach(
|
||||||
|
IEnumerable<string> tags,
|
||||||
|
Guid id,
|
||||||
|
XUserClaimsInfoDto userInfo = null,
|
||||||
|
bool forceAttachToFiles = true
|
||||||
|
);
|
||||||
|
|
||||||
|
/// <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>
|
||||||
|
Task TagsDetach(
|
||||||
|
IEnumerable<string> tags,
|
||||||
|
Guid id,
|
||||||
|
XUserClaimsInfoDto userInfo = null,
|
||||||
|
bool forceDetachFromFiles = true
|
||||||
|
);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Detach all Attached Tags for Specified File ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task TagsDetach(
|
||||||
|
Guid id,
|
||||||
|
XUserClaimsInfoDto userInfo = null
|
||||||
|
);
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -178,10 +178,16 @@ namespace xWebinarService.Providers
|
|||||||
/// Create Webinar ...
|
/// Create Webinar ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item"></param>
|
/// <param name="item"></param>
|
||||||
|
/// <param name="tags"></param>
|
||||||
|
/// <param name="files"></param>
|
||||||
|
/// <param name="userInfo"></param>
|
||||||
/// <param name="connectionId"></param>
|
/// <param name="connectionId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<XWebinarDto> CreateWebinar(
|
public async Task<XWebinarDto> CreateWebinar(
|
||||||
XWebinarDto item,
|
XWebinarDto item,
|
||||||
|
IEnumerable<string> tags = null,
|
||||||
|
IFormFileCollection files = null,
|
||||||
|
XUserClaimsInfoDto userInfo = null,
|
||||||
string connectionId = null
|
string connectionId = null
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -191,7 +197,9 @@ namespace xWebinarService.Providers
|
|||||||
!item.IsNull() &&
|
!item.IsNull() &&
|
||||||
!item.Title.IsNull() &&
|
!item.Title.IsNull() &&
|
||||||
!item.Description.IsNull() &&
|
!item.Description.IsNull() &&
|
||||||
!item.OwnerId.IsNullOrEmpty();
|
!userInfo.IsNullOrDefault() &&
|
||||||
|
!item.OwnerId.IsNullOrEmpty() &&
|
||||||
|
userInfo.UserId == item.OwnerId;
|
||||||
if (!isValid)
|
if (!isValid)
|
||||||
{
|
{
|
||||||
XException.InvalidArgs.Throw();
|
XException.InvalidArgs.Throw();
|
||||||
@@ -295,6 +303,43 @@ namespace xWebinarService.Providers
|
|||||||
XException.ActionFailed.Throw();
|
XException.ActionFailed.Throw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check For Files ...
|
||||||
|
isValid = !files.IsNull();
|
||||||
|
if (isValid)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//
|
||||||
|
await Upload(
|
||||||
|
id: entity.Id,
|
||||||
|
files: files,
|
||||||
|
userInfo: userInfo
|
||||||
|
);
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check For Tags ...
|
||||||
|
isValid = !tags.IsNull() && tags.HasChild();
|
||||||
|
if (isValid)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//
|
||||||
|
await TagsAttach(
|
||||||
|
tags: tags,
|
||||||
|
id: entity.Id,
|
||||||
|
userInfo: userInfo,
|
||||||
|
true //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
await SendPush(
|
await SendPush(
|
||||||
action: XBaseEntityHubAction.Add.GetStringValue(),
|
action: XBaseEntityHubAction.Add.GetStringValue(),
|
||||||
@@ -312,10 +357,12 @@ namespace xWebinarService.Providers
|
|||||||
/// Update a Webinar ...
|
/// Update a Webinar ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item"></param>
|
/// <param name="item"></param>
|
||||||
|
/// <param name="userInfo"></param>
|
||||||
/// <param name="connectionId"></param>
|
/// <param name="connectionId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<XWebinarDto> UpdateWebinar(
|
public async Task<XWebinarDto> UpdateWebinar(
|
||||||
XWebinarDto item,
|
XWebinarDto item,
|
||||||
|
XUserClaimsInfoDto userInfo = null,
|
||||||
string connectionId = null
|
string connectionId = null
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -323,9 +370,9 @@ namespace xWebinarService.Providers
|
|||||||
// Validate ...
|
// Validate ...
|
||||||
bool isValid =
|
bool isValid =
|
||||||
!item.Id.IsNull() &&
|
!item.Id.IsNull() &&
|
||||||
|
|
||||||
!item.IsNullOrDefault() &&
|
!item.IsNullOrDefault() &&
|
||||||
!item.Id.IsDefaultGuid() &&
|
!item.Id.IsDefaultGuid() &&
|
||||||
|
!userInfo.IsNullOrDefault() &&
|
||||||
!item.OwnerId.IsNullOrEmpty() &&
|
!item.OwnerId.IsNullOrEmpty() &&
|
||||||
!item.Title.IsNullOrDefault() &&
|
!item.Title.IsNullOrDefault() &&
|
||||||
!item.Description.IsNullOrDefault() &&
|
!item.Description.IsNullOrDefault() &&
|
||||||
@@ -345,6 +392,14 @@ namespace xWebinarService.Providers
|
|||||||
XException.InvalidArgs.Throw();
|
XException.InvalidArgs.Throw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Permissions ...
|
||||||
|
isValid = await HasPermission(item.Id, userInfo);
|
||||||
|
if (!isValid)
|
||||||
|
{
|
||||||
|
XException.NotAllowed.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check Item Exists ...
|
// Check Item Exists ...
|
||||||
isValid = await WebinarRepository.IsExistsAsync(item.Id);
|
isValid = await WebinarRepository.IsExistsAsync(item.Id);
|
||||||
@@ -679,10 +734,12 @@ namespace xWebinarService.Providers
|
|||||||
/// Remove Specified Webinar ...
|
/// Remove Specified Webinar ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="webinarId"></param>
|
/// <param name="webinarId"></param>
|
||||||
|
/// <param name="userInfo"></param>
|
||||||
/// <param name="connectionId"></param>
|
/// <param name="connectionId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<bool> RemoveWebinar(
|
public async Task<bool> RemoveWebinar(
|
||||||
Guid webinarId,
|
Guid webinarId,
|
||||||
|
XUserClaimsInfoDto userInfo = null,
|
||||||
string connectionId = null
|
string connectionId = null
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -699,6 +756,14 @@ namespace xWebinarService.Providers
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Permissions ...
|
||||||
|
result = await HasPermission(webinarId, userInfo);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
XException.NotAllowed.Throw();
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Get Entity ...
|
// Get Entity ...
|
||||||
var entity = await WebinarRepository.GetAsync(webinarId);
|
var entity = await WebinarRepository.GetAsync(webinarId);
|
||||||
@@ -731,6 +796,27 @@ namespace xWebinarService.Providers
|
|||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
|
|
||||||
|
//
|
||||||
|
// Detach Tags ...
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await TagsDetach(entity.Id, userInfo);
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
|
||||||
|
//
|
||||||
|
// Remove Files ...
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var medias = await WebinarFileProvider.GetAllFor(entity.Id);
|
||||||
|
if (!medias.IsNull() && medias.HasChild())
|
||||||
|
{
|
||||||
|
await RemoveFiles(entity.Id, string.Empty, userInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check Entity Removed ...
|
// Check Entity Removed ...
|
||||||
result = !await WebinarRepository.IsExistsAsync(webinarId);
|
result = !await WebinarRepository.IsExistsAsync(webinarId);
|
||||||
@@ -1203,6 +1289,46 @@ namespace xWebinarService.Providers
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove Specified Files ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="forProvidedId"></param>
|
||||||
|
/// <param name="ids"></param>
|
||||||
|
/// <param name="userInfo"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<IEnumerable<Guid>> RemoveFiles(
|
||||||
|
Guid id,
|
||||||
|
string ids = null,
|
||||||
|
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 = await WebinarFileProvider.Remove(
|
||||||
|
id,
|
||||||
|
ids,
|
||||||
|
userInfo
|
||||||
|
);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get Webinar Files ...
|
/// Get Webinar Files ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user