last implementation of webinar provider which required to test, builds ok ...

This commit is contained in:
2025-12-08 18:15:37 +03:30
parent c9875032aa
commit 496a985752
2 changed files with 250 additions and 2 deletions
+128 -2
View File
@@ -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>