add base requirements ...
This commit is contained in:
@@ -0,0 +1,107 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using xCommons.Extensions;
|
||||
using xPushService.Base;
|
||||
using xPushService.Constants;
|
||||
using xStringService.Models.Dtos;
|
||||
|
||||
namespace xTermsAndConditionsService.Hubs
|
||||
{
|
||||
/// <summary>
|
||||
/// a Hub for Notifing Terms and Conditions Events to Connected Clients ...
|
||||
/// </summary>
|
||||
public class XTermsHub : XBaseHub
|
||||
{
|
||||
public XTermsHub(
|
||||
ILogger<XTermsHub> logger
|
||||
) : base(logger)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
#region Hub Actions ...
|
||||
/// <summary>
|
||||
/// Add Specified Terms and Conditions ...
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task Add(
|
||||
XStringDto entity,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
var connectionId = Context.ConnectionId;
|
||||
if (!connectionId.IsNullOrEmpty())
|
||||
{
|
||||
//
|
||||
await Clients
|
||||
.AllExcept(connectionId)
|
||||
.SendAsync(
|
||||
XBaseEntityHubAction.Add.GetStringValue(),
|
||||
entity.ToJSON(camelCase: true),
|
||||
connectionId,
|
||||
cancellationToken
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deleted Specified Terms and Conditions ...
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task Delete(
|
||||
XStringDto entity,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
var connectionId = Context.ConnectionId;
|
||||
if (!connectionId.IsNullOrEmpty())
|
||||
{
|
||||
//
|
||||
await Clients
|
||||
.AllExcept(connectionId)
|
||||
.SendAsync(
|
||||
XBaseEntityHubAction.Delete.GetStringValue(),
|
||||
entity.ToJSON(camelCase: true),
|
||||
connectionId,
|
||||
cancellationToken
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Notify an Entity Updated ...
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task Update(
|
||||
XStringDto entity,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
var connectionId = Context.ConnectionId;
|
||||
if (!connectionId.IsNullOrEmpty())
|
||||
{
|
||||
//
|
||||
await Clients
|
||||
.AllExcept(connectionId)
|
||||
.SendAsync(
|
||||
XBaseEntityHubAction.Update.GetStringValue(),
|
||||
entity.ToJSON(camelCase: true),
|
||||
connectionId,
|
||||
cancellationToken
|
||||
);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user