using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.SignalR;
using Microsoft.EntityFrameworkCore.Query;
using xDataService.Configuration;
using xDataService.Interfaces;
using xIdentityService.Interfaces;
using xModels.Base;
using xModels.Dtos;
using xPushService.Base;
namespace xPushService.Interfaces
{
///
/// a Provider is a way to Manipulate Data using Repository or Services and Contains Push
/// notifications ability ...
///
///
///
public interface IXBaseEntityProvider
where TEntity : XBaseEntity
where THub : XBaseEntityHub
{
//
#region Props ...
IHubContext Hub { get; }
IXIdentityProvider IdentityProvider { get; }
IXBaseRepository Repository { get; }
XDataServiceConfiguration DataConfiguration { get; }
#endregion
//
#region Actions ...
///
/// add a new Item ...
///
///
///
///
///
///
Task AddAsync(
TEntity item,
bool saveChanges = true,
string connectionId = null,
CancellationToken cancellationToken = default
);
///
/// Update an Item values ...
///
///
///
///
///
///
///
Task UpdateAsync(
TKey id,
TEntity item,
bool saveChanges = true,
string connectionId = null,
CancellationToken cancellationToken = default
);
///
/// remove an Item by it's Id ...
///
///
///
///
///
///
///
Task RemoveAsync(
TKey id,
bool softDelete = true,
bool saveChanges = true,
string connectionId = null,
CancellationToken cancellationToken = default
);
///
/// count all exists Items ...
///
///
///
///
Task CountAsync(
bool ignoreSoftDeleteds = true,
CancellationToken cancellationToken = default
);
///
/// Check an Item exists or not ...
///
///
///
///
///
Task IsExistsAsync(
TKey id,
bool ignoreSoftDeleteds = true,
CancellationToken cancellationToken = default
);
///
/// retrieve an Item by it's Id ...
///
///
///
///
///
///
Task GetAsync(
TKey id,
bool ignoreSoftDeleteds = true,
Func, IIncludableQueryable> includeBuilder = null,
CancellationToken cancellationToken = default
);
///
/// retrieve all exists Items ...
///
///
///
///
///
///
Task> GetAllAsync(
bool ignoreSoftDeleteds = true,
Func, IOrderedQueryable> orderBuilder = null,
Func, IIncludableQueryable> includeBuilder = null,
CancellationToken cancellationToken = default
);
///
/// find an Item by providing a Conditional Expression ...
///
///
///
///
///
///
Task FindOneAsync(
Expression> predicate,
bool ignoreSoftDeleteds = true,
Func, IIncludableQueryable> includeBuilder = null,
CancellationToken cancellationToken = default
);
///
/// find a collection of Items by proving a Conditional Expression ...
///
///
///
///
///
///
///
Task> FindManyAsync(
Expression> predicate,
bool ignoreSoftDeleteds = true,
Func, IOrderedQueryable> orderBuilder = null,
Func, IIncludableQueryable> includeBuilder = null,
CancellationToken cancellationToken = default
);
///
/// retrieve Items based on XQuery Pagination structure ...
///
///
///
///
///
///
///
///
Task> QueryAsync(
XQuery query,
bool ignoreSoftDeleteds = true,
Expression> predicate = null,
Func, IOrderedQueryable> orderBuilder = null,
Func, IIncludableQueryable> includeBuilder = null,
CancellationToken cancellationToken = default
);
#endregion
//
#region Hub Actions ...
///
/// Send Custom Push Message ...
///
///
///
///
///
///
Task SendPush(
string action,
string payLoad,
string connectionId = null,
CancellationToken cancellationToken = default
);
#endregion
}
}