refactor renew ...
This commit is contained in:
@@ -51,12 +51,14 @@ namespace xPushService.Interfaces
|
||||
/// <param name="id"></param>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="saveChanges"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<TDto> UpdateAsync(
|
||||
TKey id,
|
||||
TDto item,
|
||||
bool saveChanges = true,
|
||||
string connectionId = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
@@ -66,12 +68,14 @@ namespace xPushService.Interfaces
|
||||
/// <param name="id"></param>
|
||||
/// <param name="softDelete"></param>
|
||||
/// <param name="saveChanges"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<TDto> RemoveAsync(
|
||||
TKey id,
|
||||
bool softDelete = true,
|
||||
bool saveChanges = true,
|
||||
string connectionId = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
|
||||
+144
-89
@@ -32,8 +32,6 @@ namespace xPushService.Providers
|
||||
|
||||
//
|
||||
#region Actions ...
|
||||
//
|
||||
#region Add ...
|
||||
/// <summary>
|
||||
/// add a new Dto ...
|
||||
/// </summary>
|
||||
@@ -50,7 +48,7 @@ namespace xPushService.Providers
|
||||
)
|
||||
{
|
||||
//
|
||||
TDto result = await RepositoryService.AddAsync(
|
||||
var result = await RepositoryService.AddAsync(
|
||||
item: item,
|
||||
saveChanges: saveChanges,
|
||||
cancellationToken: cancellationToken
|
||||
@@ -71,87 +69,86 @@ namespace xPushService.Providers
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
#region Update ...
|
||||
/// <summary>
|
||||
/// Update an Dto values ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="saveChanges"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<TDto> UpdateAsync(
|
||||
TKey id,
|
||||
TDto item,
|
||||
bool saveChanges = true,
|
||||
string connectionId = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await RepositoryService.UpdateAsync(
|
||||
id: id,
|
||||
item: item,
|
||||
saveChanges: saveChanges,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Update a range of Dtos ...
|
||||
/// </summary>
|
||||
/// <param name="items"></param>
|
||||
/// <param name="saveChanges"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> UpdateRangeAsync(
|
||||
IEnumerable<TDto> items,
|
||||
bool saveChanges = true,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
#endregion
|
||||
//
|
||||
if (!result.IsNullOrDefault())
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.Update.GetStringValue(),
|
||||
payLoad: result.ToJSON(camelCase: true),
|
||||
connectionId: connectionId
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
#region Remove ...
|
||||
/// <summary>
|
||||
/// remove an Dto by it's Id ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="softDelete"></param>
|
||||
/// <param name="saveChanges"></param>
|
||||
/// <param name="connectionId"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<TDto> RemoveAsync(
|
||||
TKey id,
|
||||
bool softDelete = true,
|
||||
bool saveChanges = true,
|
||||
string connectionId = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await RepositoryService.RemoveAsync(
|
||||
id: id,
|
||||
softDelete: softDelete,
|
||||
saveChanges: saveChanges,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// remove an Dto ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="softDelete"></param>
|
||||
/// <param name="saveChanges"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<TDto> RemoveAsync(
|
||||
TDto item,
|
||||
bool softDelete = true,
|
||||
bool saveChanges = true,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
//
|
||||
if (!result.IsNullOrDefault())
|
||||
{
|
||||
//
|
||||
await SendPush(
|
||||
action: XBaseEntityHubAction.Update.GetStringValue(),
|
||||
payLoad: result.ToJSON(camelCase: true),
|
||||
connectionId: connectionId
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// remove a range of exists Dtos ...
|
||||
/// </summary>
|
||||
/// <param name="items"></param>
|
||||
/// <param name="softDelete"></param>
|
||||
/// <param name="saveChanges"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task RemoveRangeAsync(
|
||||
IEnumerable<TDto> items,
|
||||
bool softDelete = true,
|
||||
bool saveChanges = true,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
#endregion
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
#region Count ...
|
||||
/// <summary>
|
||||
/// count all exists Dtos ...
|
||||
/// </summary>
|
||||
@@ -161,26 +158,42 @@ namespace xPushService.Providers
|
||||
public async Task<int> CountAsync(
|
||||
bool ignoreSoftDeleteds = true,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await RepositoryService.CountAsync(
|
||||
cancellationToken: cancellationToken,
|
||||
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// count all exists Entities Pages by providing page size ...
|
||||
/// Check a Dto exists or not ...
|
||||
/// </summary>
|
||||
/// <param name="pageSize"></param>
|
||||
/// <param name="totalItems"></param>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="ignoreSoftDeleteds"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<int> PagesCountAsync(
|
||||
int pageSize,
|
||||
int? totalItems = null,
|
||||
public async Task<bool> IsExistsAsync(
|
||||
TKey id,
|
||||
bool ignoreSoftDeleteds = true,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
#endregion
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await RepositoryService.IsExistsAsync(
|
||||
id: id,
|
||||
cancellationToken: cancellationToken,
|
||||
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
#region Retrieve ...
|
||||
/// <summary>
|
||||
/// retrieve an Dto by it's Id ...
|
||||
/// </summary>
|
||||
@@ -194,7 +207,19 @@ namespace xPushService.Providers
|
||||
bool ignoreSoftDeleteds = true,
|
||||
Func<IQueryable<TEntity>, IIncludableQueryable<TEntity, object>> includeBuilder = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await RepositoryService.GetAsync(
|
||||
id: id,
|
||||
includeBuilder: includeBuilder,
|
||||
cancellationToken: cancellationToken,
|
||||
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// retrieve all exists Dtos ...
|
||||
@@ -209,7 +234,19 @@ namespace xPushService.Providers
|
||||
Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBuilder = null,
|
||||
Func<IQueryable<TEntity>, IIncludableQueryable<TEntity, object>> includeBuilder = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await RepositoryService.GetAllAsync(
|
||||
orderBuilder: orderBuilder,
|
||||
includeBuilder: includeBuilder,
|
||||
cancellationToken: cancellationToken,
|
||||
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// find an Dto by providing a Conditional Expression ...
|
||||
@@ -224,7 +261,19 @@ namespace xPushService.Providers
|
||||
bool ignoreSoftDeleteds = true,
|
||||
Func<IQueryable<TEntity>, IIncludableQueryable<TEntity, object>> includeBuilder = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await RepositoryService.FindOneAsync(
|
||||
predicate: predicate,
|
||||
includeBuilder: includeBuilder,
|
||||
cancellationToken: cancellationToken,
|
||||
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// find a collection of Dtos by proving a Conditional Expression ...
|
||||
@@ -241,7 +290,20 @@ namespace xPushService.Providers
|
||||
Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBuilder = null,
|
||||
Func<IQueryable<TEntity>, IIncludableQueryable<TEntity, object>> includeBuilder = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await RepositoryService.FindManyAsync(
|
||||
predicate: predicate,
|
||||
orderBuilder: orderBuilder,
|
||||
includeBuilder: includeBuilder,
|
||||
cancellationToken: cancellationToken,
|
||||
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// retrieve Dtos based on XQuery Pagination structure ...
|
||||
@@ -260,24 +322,21 @@ namespace xPushService.Providers
|
||||
Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBuilder = null,
|
||||
Func<IQueryable<TEntity>, IIncludableQueryable<TEntity, object>> includeBuilder = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
#endregion
|
||||
)
|
||||
{
|
||||
//
|
||||
var result = await RepositoryService.QueryAsync(
|
||||
query: query,
|
||||
predicate: predicate,
|
||||
orderBuilder: orderBuilder,
|
||||
includeBuilder: includeBuilder,
|
||||
cancellationToken: cancellationToken,
|
||||
ignoreSoftDeleteds: ignoreSoftDeleteds
|
||||
);
|
||||
|
||||
//
|
||||
#region Exists ...
|
||||
/// <summary>
|
||||
/// Check a Dto exists or not ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="ignoreSoftDeleteds"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> IsExistsAsync(
|
||||
TKey id,
|
||||
bool ignoreSoftDeleteds = true,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
#endregion
|
||||
//
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
//
|
||||
@@ -342,8 +401,4 @@ namespace xPushService.Providers
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
internal class XTagDto
|
||||
{
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user