Preparing xPushService ...
This commit is contained in:
@@ -15,15 +15,16 @@ using xPushService.Base;
|
||||
|
||||
namespace xPushService.Interfaces
|
||||
{
|
||||
public interface IXBaseDtoProvider<TEntity, TDto, TKey>
|
||||
public interface IXBaseDtoProvider<TEntity, TDto, TKey, THub>
|
||||
where TEntity : XBaseEntity<TKey>
|
||||
where TDto : XBaseEntityDto<TKey>
|
||||
where THub : XBaseDtoHub<TEntity, TDto, TKey>
|
||||
{
|
||||
//
|
||||
#region Props ...
|
||||
IHubContext<THub> Hub { get; }
|
||||
IXIdentityProvider IdentityProvider { get; }
|
||||
XDataServiceConfiguration DataConfiguration { get; }
|
||||
IHubContext<XBaseDtoHub<TEntity, TDto, TKey>> Hub { get; }
|
||||
IXBaseRepositoryService<TEntity, TDto, TKey> Service { get; }
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -21,15 +21,16 @@ namespace xPushService.Interfaces
|
||||
/// </summary>
|
||||
/// <typeparam name="TEntity"></typeparam>
|
||||
/// <typeparam name="TKey"></typeparam>
|
||||
public interface IXBaseEntityProviderr<TEntity, TKey>
|
||||
public interface IXBaseEntityProviderr<TEntity, TKey, THub>
|
||||
where TEntity : XBaseEntity<TKey>
|
||||
where THub : XBaseEntityHub<TEntity, TKey>
|
||||
{
|
||||
//
|
||||
#region Props ...
|
||||
IHubContext<THub> Hub { get; }
|
||||
IXIdentityProvider IdentityProvider { get; }
|
||||
IXBaseRepository<TEntity, TKey> Repository { get; }
|
||||
XDataServiceConfiguration DataConfiguration { get; }
|
||||
IHubContext<XBaseEntityHub<TEntity, TKey>> Hub { get; }
|
||||
#endregion
|
||||
|
||||
//
|
||||
|
||||
@@ -0,0 +1,200 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore.Query;
|
||||
using xModels.Base;
|
||||
using xModels.Dtos;
|
||||
using xPushService.Base;
|
||||
|
||||
namespace xPushService.Interfaces
|
||||
{
|
||||
public interface IXBaseRepositoryProviderController<TEntity, TKey, THub>
|
||||
where TEntity : XBaseEntity<TKey>
|
||||
where THub : XBaseEntityHub<TEntity, TKey>
|
||||
{
|
||||
//
|
||||
#region Properties ...
|
||||
IXBaseEntityProviderr<TEntity, TKey, THub> Provider { get; }
|
||||
Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> DefaultOrderBuilder { get; }
|
||||
Func<IQueryable<TEntity>, IIncludableQueryable<TEntity, object>> DefaultIncludeBuilder { get; }
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Actions ...
|
||||
/// <summary>
|
||||
/// add a new Item ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="saveChanges"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
Task<ActionResult<TEntity>> Add(
|
||||
[FromBody] TEntity item,
|
||||
[FromQuery] bool saveChanges = true,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Update an Item values ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="saveChanges"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("{id}")]
|
||||
Task<ActionResult<TEntity>> Update(
|
||||
[FromRoute] TKey id,
|
||||
[FromBody] TEntity item,
|
||||
[FromQuery] bool saveChanges = true,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// remove an Item by it's Id ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="softDelete"></param>
|
||||
/// <param name="saveChanges"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("{id}")]
|
||||
Task<ActionResult<TEntity>> Remove(
|
||||
[FromRoute] TKey id,
|
||||
[FromQuery] bool softDelete = true,
|
||||
[FromQuery] bool saveChanges = true,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Check an Item exists or not ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="ignoreSoftDeleteds"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{id}/[action]")]
|
||||
Task<ActionResult<bool>> IsExists(
|
||||
[FromRoute] TKey id,
|
||||
[FromQuery] bool ignoreSoftDeleteds = true,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// count all exists Items ...
|
||||
/// </summary>
|
||||
/// <param name="ignoreSoftDeleteds"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Count")]
|
||||
Task<ActionResult<long>> Count(
|
||||
[FromQuery] bool ignoreSoftDeleteds = true,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// retrieve an Item by it's Id ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="ignoreSoftDeleteds"></param>
|
||||
/// <param name="useDefaultIncludes"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{id}")]
|
||||
Task<ActionResult<TEntity>> Get(
|
||||
[FromRoute] TKey id,
|
||||
[FromQuery] bool ignoreSoftDeleteds = true,
|
||||
[FromQuery] bool useDefaultIncludes = false,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// retrieve all exists Items ...
|
||||
/// </summary>
|
||||
/// <param name="ignoreSoftDeleteds"></param>
|
||||
/// <param name="useDefaultOrders"></param>
|
||||
/// <param name="useDefaultIncludes"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
Task<ActionResult<IEnumerable<TEntity>>> GetAll(
|
||||
[FromQuery] bool ignoreSoftDeleteds = true,
|
||||
[FromQuery] bool useDefaultOrders = false,
|
||||
[FromQuery] bool useDefaultIncludes = false,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// find an Item by providing a Conditional Expression ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <param name="ignoreSoftDeleteds"></param>
|
||||
/// <param name="useDefaultIncludes"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<ActionResult<TEntity>> FindOne(
|
||||
[FromRoute] string query,
|
||||
[FromQuery] bool ignoreSoftDeleteds = true,
|
||||
[FromQuery] bool useDefaultIncludes = false,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// find a collection of Items by proving a Conditional Expression ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <param name="ignoreSoftDeleteds"></param>
|
||||
/// <param name="useDefaultOrders"></param>
|
||||
/// <param name="useDefaultIncludes"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<ActionResult<IEnumerable<TEntity>>> FindMany(
|
||||
[FromRoute] string query,
|
||||
[FromQuery] bool ignoreSoftDeleteds = true,
|
||||
[FromQuery] bool useDefaultOrders = false,
|
||||
[FromQuery] bool useDefaultIncludes = false,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// retrieve Items based on XQuery Pagination structure ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <param name="ignoreSoftDeleteds"></param>
|
||||
/// <param name="useDefaultOrders"></param>
|
||||
/// <param name="useDefaultIncludes"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<ActionResult<XQueryResult<TEntity>>> Query(
|
||||
[FromQuery] XQuery query,
|
||||
[FromQuery] bool ignoreSoftDeleteds = true,
|
||||
[FromQuery] bool useDefaultOrders = false,
|
||||
[FromQuery] bool useDefaultIncludes = false,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Non Actions ...
|
||||
/// <summary>
|
||||
/// Send Custom Push Message ...
|
||||
/// </summary>
|
||||
/// <param name="action"></param>
|
||||
/// <param name="payLoad"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[NonAction]
|
||||
Task SendPush(
|
||||
string action,
|
||||
string payLoad,
|
||||
string connectionId = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore.Query;
|
||||
using xModels.Base;
|
||||
using xModels.Dtos;
|
||||
using xPushService.Base;
|
||||
|
||||
namespace xPushService.Interfaces
|
||||
{
|
||||
public interface IXBaseServiceProviderController<TEntity, TDto, TKey, THub>
|
||||
where TEntity : XBaseEntity<TKey>
|
||||
where TDto : XBaseEntityDto<TKey>
|
||||
where THub : XBaseDtoHub<TEntity, TDto, TKey>
|
||||
{
|
||||
//
|
||||
#region Properties ...
|
||||
IXBaseDtoProvider<TEntity, TDto, TKey, THub> Provider { get; }
|
||||
Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> DefaultOrderBuilder { get; }
|
||||
Func<IQueryable<TEntity>, IIncludableQueryable<TEntity, object>> DefaultIncludeBuilder { get; }
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Actions ...
|
||||
/// <summary>
|
||||
/// add a new Item ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="saveChanges"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
Task<ActionResult<TDto>> Add(
|
||||
[FromBody] TDto item,
|
||||
[FromQuery] bool saveChanges = true,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Update an Item values ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="saveChanges"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("{id}")]
|
||||
Task<ActionResult<TDto>> Update(
|
||||
[FromRoute] TKey id,
|
||||
[FromBody] TDto item,
|
||||
[FromQuery] bool saveChanges = true,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// remove an Item by it's Id ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="softDelete"></param>
|
||||
/// <param name="saveChanges"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("{id}")]
|
||||
Task<ActionResult<TDto>> Remove(
|
||||
[FromRoute] TKey id,
|
||||
[FromQuery] bool softDelete = true,
|
||||
[FromQuery] bool saveChanges = true,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Check an Item exists or not ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="ignoreSoftDeleteds"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{id}/[action]")]
|
||||
Task<ActionResult<bool>> IsExists(
|
||||
[FromRoute] TKey id,
|
||||
[FromQuery] bool ignoreSoftDeleteds = true,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// count all exists Items ...
|
||||
/// </summary>
|
||||
/// <param name="ignoreSoftDeleteds"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Count")]
|
||||
Task<ActionResult<long>> Count(
|
||||
[FromQuery] bool ignoreSoftDeleteds = true,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// retrieve an Item by it's Id ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="ignoreSoftDeleteds"></param>
|
||||
/// <param name="useDefaultIncludes"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{id}")]
|
||||
Task<ActionResult<TDto>> Get(
|
||||
[FromRoute] TKey id,
|
||||
[FromQuery] bool ignoreSoftDeleteds = true,
|
||||
[FromQuery] bool useDefaultIncludes = false,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// retrieve all exists Items ...
|
||||
/// </summary>
|
||||
/// <param name="ignoreSoftDeleteds"></param>
|
||||
/// <param name="useDefaultOrders"></param>
|
||||
/// <param name="useDefaultIncludes"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
Task<ActionResult<IEnumerable<TDto>>> GetAll(
|
||||
[FromQuery] bool ignoreSoftDeleteds = true,
|
||||
[FromQuery] bool useDefaultOrders = false,
|
||||
[FromQuery] bool useDefaultIncludes = false,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// find an Item by providing a Conditional Expression ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <param name="ignoreSoftDeleteds"></param>
|
||||
/// <param name="useDefaultIncludes"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<ActionResult<TDto>> FindOne(
|
||||
[FromRoute] string query,
|
||||
[FromQuery] bool ignoreSoftDeleteds = true,
|
||||
[FromQuery] bool useDefaultIncludes = false,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// find a collection of Items by proving a Conditional Expression ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <param name="ignoreSoftDeleteds"></param>
|
||||
/// <param name="useDefaultOrders"></param>
|
||||
/// <param name="useDefaultIncludes"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<ActionResult<IEnumerable<TDto>>> FindMany(
|
||||
[FromRoute] string query,
|
||||
[FromQuery] bool ignoreSoftDeleteds = true,
|
||||
[FromQuery] bool useDefaultOrders = false,
|
||||
[FromQuery] bool useDefaultIncludes = false,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// retrieve Items based on XQuery Pagination structure ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <param name="ignoreSoftDeleteds"></param>
|
||||
/// <param name="useDefaultOrders"></param>
|
||||
/// <param name="useDefaultIncludes"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<ActionResult<XQueryResult<TDto>>> Query(
|
||||
[FromQuery] XQuery query,
|
||||
[FromQuery] bool ignoreSoftDeleteds = true,
|
||||
[FromQuery] bool useDefaultOrders = false,
|
||||
[FromQuery] bool useDefaultIncludes = false,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Non Actions ...
|
||||
/// <summary>
|
||||
/// Send Custom Push Message ...
|
||||
/// </summary>
|
||||
/// <param name="action"></param>
|
||||
/// <param name="payLoad"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[NonAction]
|
||||
Task SendPush(
|
||||
string action,
|
||||
string payLoad,
|
||||
string connectionId = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
|
||||
namespace xPushService.Interfaces
|
||||
{
|
||||
public interface IXHubContextFactory
|
||||
{
|
||||
IHubContext<THub> Create<THub>() where THub : Hub;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user