-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from RicardoZambon/fix/add-di
fix: add dependency injection
- Loading branch information
Showing
3 changed files
with
78 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Microsoft.Extensions.DependencyInjection; | ||
using ZDatabase.Entities.Audit; | ||
using ZWebAPI.Services; | ||
using ZWebAPI.Services.Interfaces; | ||
|
||
namespace ZWebAPI.ExtensionMethods | ||
{ | ||
/// <summary> | ||
/// Extension methods for <see cref="Microsoft.Extensions.DependencyInjection.IServiceCollection"/>. | ||
/// </summary> | ||
public static class DependencyInjectionExtensions | ||
{ | ||
/// <summary> | ||
/// Adds the audit handler service to the service collection. | ||
/// </summary> | ||
/// <typeparam name="TAuditHandler">The type of the audit handler.</typeparam> | ||
/// <param name="services">The services.</param> | ||
/// <returns>The service collection.</returns> | ||
public static IServiceCollection AddAuditService<TServicesHistory, TOperationsHistory, TUsers, TUsersKey>(this IServiceCollection services) | ||
where TServicesHistory : ServicesHistory<TServicesHistory, TOperationsHistory, TUsers, TUsersKey>, new() | ||
where TOperationsHistory : OperationsHistory<TServicesHistory, TOperationsHistory, TUsers, TUsersKey>, new() | ||
where TUsers : class | ||
where TUsersKey : struct | ||
=> services | ||
.AddScoped<IAuditService<TUsers, TUsersKey>, AuditServiceDefault<TServicesHistory, TOperationsHistory, TUsers, TUsersKey>>(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using Microsoft.EntityFrameworkCore.ChangeTracking; | ||
using ZDatabase.Entities; | ||
using ZWebAPI.Interfaces; | ||
using ZWebAPI.Models.Audit.OperationHistory; | ||
using ZWebAPI.Models.Audit.ServiceHistory; | ||
|
||
namespace ZWebAPI.Services.Interfaces | ||
{ | ||
/// <summary> | ||
/// Service to handle audit services and operations. | ||
/// </summary> | ||
/// <typeparam name="TUsers">The type of the users.</typeparam> | ||
/// <typeparam name="TUsersKey">The type of the users key.</typeparam> | ||
public interface IAuditService<TUsers, TUsersKey> | ||
where TUsers : class | ||
where TUsersKey : struct | ||
{ | ||
/// <summary> | ||
/// Adds the operation history asynchronous. | ||
/// </summary> | ||
/// <typeparam name="TEntity">The type of the entity.</typeparam> | ||
/// <param name="entityEntry">The entity entry.</param> | ||
Task AddOperationHistoryAsync<TEntity>(EntityEntry<TEntity> entityEntry) where TEntity : AuditableEntity<TUsers, TUsersKey>; | ||
|
||
/// <summary> | ||
/// Begins a new service history asynchronous. | ||
/// </summary> | ||
Task BeginNewServiceHistoryAsync(); | ||
|
||
/// <summary> | ||
/// Lists the operations history from the service history identifier. | ||
/// </summary> | ||
/// <typeparam name="TEntity">The type of the entity.</typeparam> | ||
/// <param name="serviceHistoryID">The service history identifier.</param> | ||
/// <param name="parameters">The parameters.</param> | ||
/// <returns>Query with all operations history from the service history identifier.</returns> | ||
IQueryable<OperationsHistoryListModel> ListEntityOperationsHistory<TEntity>(long serviceHistoryID, IListParameters parameters) where TEntity : AuditableEntity<TUsers, TUsersKey>; | ||
|
||
/// <summary> | ||
/// Lists the services history from an entity identifier asynchronous. | ||
/// </summary> | ||
/// <typeparam name="TEntity">The type of the entity.</typeparam> | ||
/// <param name="entityID">The entity identifier.</param> | ||
/// <param name="parameters">The parameters.</param> | ||
/// <returns>Query with all services history from the entity identifier.</returns> | ||
Task<IQueryable<ServicesHistoryListModel>> ListEntityServicesHistoryAsync<TEntity>(long entityID, IListParameters parameters) where TEntity : AuditableEntity<TUsers, TUsersKey>; | ||
} | ||
} |