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