Enhance framework compatibility and code readability
Added preprocessor directives for .NET framework compatibility. Modified `using` directives to be framework-specific. Improved code formatting for better readability. Introduced obsolete attributes for deprecated methods, recommending `MediatR` as an alternative. Added XML documentation for clarity and maintainability.
This commit is contained in:
parent
07ab7f0c62
commit
74a625a863
@ -1,4 +1,5 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
#if NET
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System.Configuration;
|
||||
|
||||
@ -32,3 +33,4 @@ public static class DIExtensions
|
||||
return services;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -1,4 +1,5 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
#if NET
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Text;
|
||||
|
||||
namespace DigitalData.Core.Abstraction.Application.DTO;
|
||||
@ -19,7 +20,7 @@ public static class DTOExtensions
|
||||
[Obsolete("Use DigitalData.Core.Exceptions and .Middleware")]
|
||||
public static T Message<T>(this T result, string? message) where T : Result
|
||||
{
|
||||
if(message is not null)
|
||||
if (message is not null)
|
||||
result.Messages.Add(message);
|
||||
return result;
|
||||
}
|
||||
@ -28,7 +29,7 @@ public static class DTOExtensions
|
||||
internal static IEnumerable<T> FilterNull<T>(this IEnumerable<T?> list)
|
||||
{
|
||||
foreach (var item in list)
|
||||
if(item is not null)
|
||||
if (item is not null)
|
||||
yield return item;
|
||||
}
|
||||
|
||||
@ -342,7 +343,7 @@ public static class DTOExtensions
|
||||
[Obsolete("Use DigitalData.Core.Exceptions and .Middleware")]
|
||||
public static void LogNotice(this ILogger logger, IEnumerable<Notice> notices, string start = ": ", string seperator = ". ", string end = ".\n")
|
||||
{
|
||||
foreach(LogLevel level in Enum.GetValues(typeof(LogLevel)))
|
||||
foreach (LogLevel level in Enum.GetValues(typeof(LogLevel)))
|
||||
{
|
||||
var logNotices = notices.Where(n => n.Level == level);
|
||||
|
||||
@ -350,7 +351,7 @@ public static class DTOExtensions
|
||||
continue;
|
||||
|
||||
var sb = new StringBuilder();
|
||||
foreach(Notice notice in logNotices)
|
||||
foreach (Notice notice in logNotices)
|
||||
{
|
||||
if (notice.Flag is not null)
|
||||
sb.Append(notice.Flag);
|
||||
@ -391,3 +392,4 @@ public static class DTOExtensions
|
||||
[Obsolete("Use DigitalData.Core.Exceptions and .Middleware")]
|
||||
public static bool IsWrong(this DataResult<bool> bResult) => !bResult.Data;
|
||||
}
|
||||
#endif
|
||||
@ -1,4 +1,5 @@
|
||||
namespace DigitalData.Core.Abstraction.Application.DTO;
|
||||
#if NET
|
||||
namespace DigitalData.Core.Abstraction.Application.DTO;
|
||||
|
||||
/// <summary>
|
||||
/// Defines flags that indicate specific types of status or conditions in a service operation.
|
||||
@ -48,3 +49,4 @@ public enum Flag
|
||||
/// </summary>
|
||||
NotFound
|
||||
}
|
||||
#endif
|
||||
@ -1,4 +1,5 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
#if NET
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace DigitalData.Core.Abstraction.Application.DTO;
|
||||
|
||||
@ -26,3 +27,4 @@ public class Notice
|
||||
[Obsolete("Use DigitalData.Core.Exceptions and .Middleware")]
|
||||
public List<string> Messages { get; init; } = new();
|
||||
}
|
||||
#endif
|
||||
@ -1,4 +1,5 @@
|
||||
using System.Text.Json.Serialization;
|
||||
#if NET
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace DigitalData.Core.Abstraction.Application.DTO;
|
||||
|
||||
@ -106,3 +107,4 @@ public class Result
|
||||
};
|
||||
#pragma warning restore CS8601 // Possible null reference assignment.
|
||||
}
|
||||
#endif
|
||||
@ -1,4 +1,5 @@
|
||||
namespace DigitalData.Core.Abstraction.Application;
|
||||
#if NET
|
||||
namespace DigitalData.Core.Abstraction.Application;
|
||||
|
||||
/// <summary>
|
||||
/// Provides extension methods for retrieving the value of an 'Id' property from objects.
|
||||
@ -92,3 +93,4 @@ public static class EntityExtensions
|
||||
return id is not null;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -1,4 +1,5 @@
|
||||
namespace DigitalData.Core.Abstraction.Application
|
||||
#if NET
|
||||
namespace DigitalData.Core.Abstraction.Application
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements a simplified CRUD service interface that uses a single Data Transfer Object (DTO) type for all CRUD operations,
|
||||
@ -19,3 +20,4 @@
|
||||
{
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -1,25 +1,26 @@
|
||||
using DigitalData.Core.Abstraction.Application.DTO;
|
||||
#if NET
|
||||
using DigitalData.Core.Abstraction.Application.DTO;
|
||||
|
||||
namespace DigitalData.Core.Abstraction.Application
|
||||
namespace DigitalData.Core.Abstraction.Application;
|
||||
|
||||
[Obsolete("Use MediatR")]
|
||||
public interface ICRUDService<TCreateDto, TReadDto, TEntity, TId> : IReadService<TReadDto, TEntity, TId>
|
||||
where TCreateDto : class where TReadDto : class where TEntity : class
|
||||
{
|
||||
[Obsolete("Use MediatR")]
|
||||
public interface ICRUDService<TCreateDto, TReadDto, TEntity, TId> : IReadService<TReadDto, TEntity, TId>
|
||||
where TCreateDto : class where TReadDto : class where TEntity : class
|
||||
{
|
||||
/// <summary>
|
||||
/// Asynchronously creates a new entity based on the provided <paramref name="createDto"/> and returns the identifier of the created entity wrapped in a <see cref="DataResult{TId}"/>.
|
||||
/// The <see cref="DataResult{TId}"/> contains the identifier of the newly created entity on success or an error message on failure.
|
||||
/// </summary>
|
||||
/// <param name="createDto">The data transfer object containing the information for the new entity.</param>
|
||||
/// <returns>A task representing the asynchronous operation, with a <see cref="DataResult{TId}"/> containing the identifier of the created entity or an error message.</returns>
|
||||
Task<DataResult<TReadDto>> CreateAsync(TCreateDto createDto);
|
||||
/// <summary>
|
||||
/// Asynchronously creates a new entity based on the provided <paramref name="createDto"/> and returns the identifier of the created entity wrapped in a <see cref="DataResult{TId}"/>.
|
||||
/// The <see cref="DataResult{TId}"/> contains the identifier of the newly created entity on success or an error message on failure.
|
||||
/// </summary>
|
||||
/// <param name="createDto">The data transfer object containing the information for the new entity.</param>
|
||||
/// <returns>A task representing the asynchronous operation, with a <see cref="DataResult{TId}"/> containing the identifier of the created entity or an error message.</returns>
|
||||
Task<DataResult<TReadDto>> CreateAsync(TCreateDto createDto);
|
||||
|
||||
/// <summary>
|
||||
/// Updates an existing entity based on the provided updateDTO and returns the result wrapped in an IServiceMessage,
|
||||
/// indicating the success or failure of the operation, including the error messages on failure.
|
||||
/// </summary>
|
||||
/// <param name="updateDto">The updateDTO with updated values for the entity.</param>
|
||||
/// <returns>An Result indicating the outcome of the update operation, with an appropriate message.</returns>
|
||||
Task<Result> UpdateAsync<TUpdateDto>(TUpdateDto updateDto);
|
||||
}
|
||||
/// <summary>
|
||||
/// Updates an existing entity based on the provided updateDTO and returns the result wrapped in an IServiceMessage,
|
||||
/// indicating the success or failure of the operation, including the error messages on failure.
|
||||
/// </summary>
|
||||
/// <param name="updateDto">The updateDTO with updated values for the entity.</param>
|
||||
/// <returns>An Result indicating the outcome of the update operation, with an appropriate message.</returns>
|
||||
Task<Result> UpdateAsync<TUpdateDto>(TUpdateDto updateDto);
|
||||
}
|
||||
#endif
|
||||
@ -1,94 +1,96 @@
|
||||
using DigitalData.Core.Abstraction.Application.DTO;
|
||||
#if NET
|
||||
using DigitalData.Core.Abstraction.Application.DTO;
|
||||
using System.DirectoryServices;
|
||||
|
||||
namespace DigitalData.Core.Abstraction.Application
|
||||
namespace DigitalData.Core.Abstraction.Application;
|
||||
|
||||
[Obsolete("Use DigitalData.ActiveDirectory")]
|
||||
public interface IDirectorySearchService
|
||||
{
|
||||
public interface IDirectorySearchService
|
||||
{
|
||||
public string ServerName { get; }
|
||||
public string ServerName { get; }
|
||||
|
||||
public string Root { get; }
|
||||
public string Root { get; }
|
||||
|
||||
string SearchRootPath { get; }
|
||||
string SearchRootPath { get; }
|
||||
|
||||
Dictionary<string, string> CustomSearchFilters { get; }
|
||||
Dictionary<string, string> CustomSearchFilters { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Creates the connections to the server and returns a Boolean value that specifies
|
||||
/// whether the specified username and password are valid.
|
||||
/// </summary>
|
||||
/// <param name="userName">The username that is validated on the server. See the Remarks section
|
||||
/// for more information on the format of userName.</param>
|
||||
/// <param name="password">The password that is validated on the server.</param>
|
||||
/// <returns>True if the credentials are valid; otherwise, false.</returns>
|
||||
bool ValidateCredentials(string userName, string password);
|
||||
/// <summary>
|
||||
/// Creates the connections to the server and returns a Boolean value that specifies
|
||||
/// whether the specified username and password are valid.
|
||||
/// </summary>
|
||||
/// <param name="userName">The username that is validated on the server. See the Remarks section
|
||||
/// for more information on the format of userName.</param>
|
||||
/// <param name="password">The password that is validated on the server.</param>
|
||||
/// <returns>True if the credentials are valid; otherwise, false.</returns>
|
||||
bool ValidateCredentials(string userName, string password);
|
||||
|
||||
/// <summary>
|
||||
/// Creates the connections to the server asynchronously and returns a Boolean value that specifies
|
||||
/// whether the specified username and password are valid.
|
||||
/// </summary>
|
||||
/// <param name="userName">The username that is validated on the server. See the Remarks section
|
||||
/// for more information on the format of userName.</param>
|
||||
/// <param name="password">The password that is validated on the server.</param>
|
||||
/// <returns>True if the credentials are valid; otherwise, false.</returns>
|
||||
Task<bool> ValidateCredentialsAsync(string userName, string password);
|
||||
/// <summary>
|
||||
/// Creates the connections to the server asynchronously and returns a Boolean value that specifies
|
||||
/// whether the specified username and password are valid.
|
||||
/// </summary>
|
||||
/// <param name="userName">The username that is validated on the server. See the Remarks section
|
||||
/// for more information on the format of userName.</param>
|
||||
/// <param name="password">The password that is validated on the server.</param>
|
||||
/// <returns>True if the credentials are valid; otherwise, false.</returns>
|
||||
Task<bool> ValidateCredentialsAsync(string userName, string password);
|
||||
|
||||
/// <summary>
|
||||
/// Finds all directory entries matching the specified filter.
|
||||
/// </summary>
|
||||
/// <param name="searchRoot">The search root.</param>
|
||||
/// <param name="filter">The search filter.</param>
|
||||
/// <param name="searchScope">The search scope.</param>
|
||||
/// <param name="sizeLimit">The size limit.</param>
|
||||
/// <param name="properties">The properties to load.</param>
|
||||
/// <returns>A <see cref="DataResult{T}"/> containing the results.</returns>
|
||||
DataResult<IEnumerable<ResultPropertyCollection>> FindAll(DirectoryEntry searchRoot, string filter, SearchScope searchScope = SearchScope.Subtree, int sizeLimit = 5000, params string[] properties);
|
||||
/// <summary>
|
||||
/// Finds all directory entries matching the specified filter.
|
||||
/// </summary>
|
||||
/// <param name="searchRoot">The search root.</param>
|
||||
/// <param name="filter">The search filter.</param>
|
||||
/// <param name="searchScope">The search scope.</param>
|
||||
/// <param name="sizeLimit">The size limit.</param>
|
||||
/// <param name="properties">The properties to load.</param>
|
||||
/// <returns>A <see cref="DataResult{T}"/> containing the results.</returns>
|
||||
DataResult<IEnumerable<ResultPropertyCollection>> FindAll(DirectoryEntry searchRoot, string filter, SearchScope searchScope = SearchScope.Subtree, int sizeLimit = 5000, params string[] properties);
|
||||
|
||||
/// <summary>
|
||||
/// Finds all directory entries matching the specified filter asynchronously.
|
||||
/// </summary>
|
||||
/// <param name="searchRoot">The search root.</param>
|
||||
/// <param name="filter">The search filter.</param>
|
||||
/// <param name="searchScope">The search scope.</param>
|
||||
/// <param name="sizeLimit">The size limit.</param>
|
||||
/// <param name="properties">The properties to load.</param>
|
||||
/// <returns>A <see cref="DataResult{T}"/> containing the results.</returns>
|
||||
Task<DataResult<IEnumerable<ResultPropertyCollection>>> FindAllAsync(DirectoryEntry searchRoot, string filter, SearchScope searchScope = SearchScope.Subtree, int sizeLimit = 5000, params string[] properties);
|
||||
/// <summary>
|
||||
/// Finds all directory entries matching the specified filter asynchronously.
|
||||
/// </summary>
|
||||
/// <param name="searchRoot">The search root.</param>
|
||||
/// <param name="filter">The search filter.</param>
|
||||
/// <param name="searchScope">The search scope.</param>
|
||||
/// <param name="sizeLimit">The size limit.</param>
|
||||
/// <param name="properties">The properties to load.</param>
|
||||
/// <returns>A <see cref="DataResult{T}"/> containing the results.</returns>
|
||||
Task<DataResult<IEnumerable<ResultPropertyCollection>>> FindAllAsync(DirectoryEntry searchRoot, string filter, SearchScope searchScope = SearchScope.Subtree, int sizeLimit = 5000, params string[] properties);
|
||||
|
||||
/// <summary>
|
||||
/// Finds all directory entries matching the specified filter, using the user cache.
|
||||
/// </summary>
|
||||
/// <param name="username">The username.</param>
|
||||
/// <param name="filter">The search filter.</param>
|
||||
/// <param name="searchScope">The search scope.</param>
|
||||
/// <param name="sizeLimit">The size limit.</param>
|
||||
/// <param name="properties">The properties to load.</param>
|
||||
/// <returns>A <see cref="DataResult{T}"/> containing the results.</returns>
|
||||
DataResult<IEnumerable<ResultPropertyCollection>> FindAllByUserCache(string username, string filter, SearchScope searchScope = SearchScope.Subtree, int sizeLimit = 5000, params string[] properties);
|
||||
/// <summary>
|
||||
/// Finds all directory entries matching the specified filter, using the user cache.
|
||||
/// </summary>
|
||||
/// <param name="username">The username.</param>
|
||||
/// <param name="filter">The search filter.</param>
|
||||
/// <param name="searchScope">The search scope.</param>
|
||||
/// <param name="sizeLimit">The size limit.</param>
|
||||
/// <param name="properties">The properties to load.</param>
|
||||
/// <returns>A <see cref="DataResult{T}"/> containing the results.</returns>
|
||||
DataResult<IEnumerable<ResultPropertyCollection>> FindAllByUserCache(string username, string filter, SearchScope searchScope = SearchScope.Subtree, int sizeLimit = 5000, params string[] properties);
|
||||
|
||||
/// <summary>
|
||||
/// Finds all directory entries matching the specified filter asynchronously, using the user cache.
|
||||
/// </summary>
|
||||
/// <param name="username">The username.</param>
|
||||
/// <param name="filter">The search filter.</param>
|
||||
/// <param name="searchScope">The search scope.</param>
|
||||
/// <param name="sizeLimit">The size limit.</param>
|
||||
/// <param name="properties">The properties to load.</param>
|
||||
/// <returns>A <see cref="DataResult{T}"/> containing the results.</returns>
|
||||
Task<DataResult<IEnumerable<ResultPropertyCollection>>> FindAllByUserCacheAsync(string username, string filter, SearchScope searchScope = SearchScope.Subtree, int sizeLimit = 5000, params string[] properties);
|
||||
/// <summary>
|
||||
/// Finds all directory entries matching the specified filter asynchronously, using the user cache.
|
||||
/// </summary>
|
||||
/// <param name="username">The username.</param>
|
||||
/// <param name="filter">The search filter.</param>
|
||||
/// <param name="searchScope">The search scope.</param>
|
||||
/// <param name="sizeLimit">The size limit.</param>
|
||||
/// <param name="properties">The properties to load.</param>
|
||||
/// <returns>A <see cref="DataResult{T}"/> containing the results.</returns>
|
||||
Task<DataResult<IEnumerable<ResultPropertyCollection>>> FindAllByUserCacheAsync(string username, string filter, SearchScope searchScope = SearchScope.Subtree, int sizeLimit = 5000, params string[] properties);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the search root in the cache.
|
||||
/// </summary>
|
||||
/// <param name="username">The directory entry username.</param>
|
||||
/// <param name="password">The directory entry password.</param>
|
||||
void SetSearchRootCache(string username, string password);
|
||||
/// <summary>
|
||||
/// Sets the search root in the cache.
|
||||
/// </summary>
|
||||
/// <param name="username">The directory entry username.</param>
|
||||
/// <param name="password">The directory entry password.</param>
|
||||
void SetSearchRootCache(string username, string password);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the search root from the cache.
|
||||
/// </summary>
|
||||
/// <param name="username">The directory entry username.</param>
|
||||
/// <returns>The cached <see cref="DirectoryEntry"/> if found; otherwise, null.</returns>
|
||||
DirectoryEntry? GetSearchRootCache(string username);
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the search root from the cache.
|
||||
/// </summary>
|
||||
/// <param name="username">The directory entry username.</param>
|
||||
/// <returns>The cached <see cref="DirectoryEntry"/> if found; otherwise, null.</returns>
|
||||
DirectoryEntry? GetSearchRootCache(string username);
|
||||
}
|
||||
#endif
|
||||
@ -1,41 +1,42 @@
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
#if NET
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace DigitalData.Core.Abstraction.Application
|
||||
namespace DigitalData.Core.Abstraction.Application;
|
||||
|
||||
/// <summary>
|
||||
/// Defines the operations for JWT service handling claims of type <typeparamref name="TClaimValue"/>.
|
||||
/// </summary>
|
||||
public interface IJWTService<TClaimValue>
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the operations for JWT service handling claims of type <typeparamref name="TClaimValue"/>.
|
||||
/// Generates a symmetric security key with the specified byte size.
|
||||
/// </summary>
|
||||
public interface IJWTService<TClaimValue>
|
||||
/// <param name="byteSize">The size of the security key in bytes. Default is 32 bytes.</param>
|
||||
/// <returns>A new instance of <see cref="SymmetricSecurityKey"/>.</returns>
|
||||
public static SymmetricSecurityKey GenerateSecurityKey(int byteSize = 32)
|
||||
{
|
||||
/// <summary>
|
||||
/// Generates a symmetric security key with the specified byte size.
|
||||
/// </summary>
|
||||
/// <param name="byteSize">The size of the security key in bytes. Default is 32 bytes.</param>
|
||||
/// <returns>A new instance of <see cref="SymmetricSecurityKey"/>.</returns>
|
||||
public static SymmetricSecurityKey GenerateSecurityKey(int byteSize = 32)
|
||||
{
|
||||
using var rng = RandomNumberGenerator.Create();
|
||||
var randomBytes = new byte[byteSize];
|
||||
rng.GetBytes(randomBytes);
|
||||
var securityKey = new SymmetricSecurityKey(randomBytes);
|
||||
using var rng = RandomNumberGenerator.Create();
|
||||
var randomBytes = new byte[byteSize];
|
||||
rng.GetBytes(randomBytes);
|
||||
var securityKey = new SymmetricSecurityKey(randomBytes);
|
||||
|
||||
return securityKey;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates a token based on the specified claim value.
|
||||
/// </summary>
|
||||
/// <param name="claimValue">The claim value to encode in the token.</param>
|
||||
/// <returns>A JWT as a string.</returns>
|
||||
string GenerateToken(TClaimValue claimValue);
|
||||
|
||||
/// <summary>
|
||||
/// Reads and validates a security token from a string representation.
|
||||
/// </summary>
|
||||
/// <param name="token">The JWT to read.</param>
|
||||
/// <returns>A <see cref="JwtSecurityToken"/> if the token is valid; otherwise, null.</returns>
|
||||
JwtSecurityToken? ReadSecurityToken(string token);
|
||||
return securityKey;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates a token based on the specified claim value.
|
||||
/// </summary>
|
||||
/// <param name="claimValue">The claim value to encode in the token.</param>
|
||||
/// <returns>A JWT as a string.</returns>
|
||||
string GenerateToken(TClaimValue claimValue);
|
||||
|
||||
/// <summary>
|
||||
/// Reads and validates a security token from a string representation.
|
||||
/// </summary>
|
||||
/// <param name="token">The JWT to read.</param>
|
||||
/// <returns>A <see cref="JwtSecurityToken"/> if the token is valid; otherwise, null.</returns>
|
||||
JwtSecurityToken? ReadSecurityToken(string token);
|
||||
}
|
||||
#endif
|
||||
@ -1,39 +1,40 @@
|
||||
using DigitalData.Core.Abstraction.Application.DTO;
|
||||
#if NET
|
||||
using DigitalData.Core.Abstraction.Application.DTO;
|
||||
|
||||
namespace DigitalData.Core.Abstraction.Application
|
||||
namespace DigitalData.Core.Abstraction.Application;
|
||||
|
||||
[Obsolete("Use MediatR")]
|
||||
public interface IReadService<TReadDto, TEntity, TId>
|
||||
where TReadDto : class where TEntity : class
|
||||
{
|
||||
[Obsolete("Use MediatR")]
|
||||
public interface IReadService<TReadDto, TEntity, TId>
|
||||
where TReadDto : class where TEntity : class
|
||||
{
|
||||
/// <summary>
|
||||
/// Retrieves an entity by its identifier and returns its readDTO representation wrapped in an IServiceResult,
|
||||
/// including the readDTO on success or null and an error message on failure.
|
||||
/// </summary>
|
||||
/// <param name="id">The identifier of the entity to retrieve.</param>
|
||||
/// <returns>An DataResult containing the readDTO representing the found entity or null, with an appropriate message.</returns>
|
||||
Task<DataResult<TReadDto>> ReadByIdAsync(TId id);
|
||||
/// <summary>
|
||||
/// Retrieves an entity by its identifier and returns its readDTO representation wrapped in an IServiceResult,
|
||||
/// including the readDTO on success or null and an error message on failure.
|
||||
/// </summary>
|
||||
/// <param name="id">The identifier of the entity to retrieve.</param>
|
||||
/// <returns>An DataResult containing the readDTO representing the found entity or null, with an appropriate message.</returns>
|
||||
Task<DataResult<TReadDto>> ReadByIdAsync(TId id);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all entities and returns their readDTO representations wrapped in an IServiceResult,
|
||||
/// including a collection of readDTOs on success or an error message on failure.
|
||||
/// </summary>
|
||||
/// <returns>An DataResult containing a collection of readDTOs representing all entities or an error message.</returns>
|
||||
Task<DataResult<IEnumerable<TReadDto>>> ReadAllAsync();
|
||||
/// <summary>
|
||||
/// Retrieves all entities and returns their readDTO representations wrapped in an IServiceResult,
|
||||
/// including a collection of readDTOs on success or an error message on failure.
|
||||
/// </summary>
|
||||
/// <returns>An DataResult containing a collection of readDTOs representing all entities or an error message.</returns>
|
||||
Task<DataResult<IEnumerable<TReadDto>>> ReadAllAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Deletes an entity by its identifier and returns the result wrapped in an IServiceMessage,
|
||||
/// indicating the success or failure of the operation, including the error messages on failure.
|
||||
/// </summary>
|
||||
/// <param name="id">The identifier of the entity to delete.</param>
|
||||
/// <returns>An Result indicating the outcome of the delete operation, with an appropriate message.</returns>
|
||||
Task<Result> DeleteAsyncById(TId id);
|
||||
/// <summary>
|
||||
/// Deletes an entity by its identifier and returns the result wrapped in an IServiceMessage,
|
||||
/// indicating the success or failure of the operation, including the error messages on failure.
|
||||
/// </summary>
|
||||
/// <param name="id">The identifier of the entity to delete.</param>
|
||||
/// <returns>An Result indicating the outcome of the delete operation, with an appropriate message.</returns>
|
||||
Task<Result> DeleteAsyncById(TId id);
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously checks if an entity with the specified identifier exists within the data store.
|
||||
/// </summary>
|
||||
/// <param name="id">The identifier of the entity to check.</param>
|
||||
/// <returns>A task that represents the asynchronous operation. The task result contains a boolean value indicating whether the entity exists.</returns>
|
||||
Task<bool> HasEntity(TId id);
|
||||
}
|
||||
/// <summary>
|
||||
/// Asynchronously checks if an entity with the specified identifier exists within the data store.
|
||||
/// </summary>
|
||||
/// <param name="id">The identifier of the entity to check.</param>
|
||||
/// <returns>A task that represents the asynchronous operation. The task result contains a boolean value indicating whether the entity exists.</returns>
|
||||
Task<bool> HasEntity(TId id);
|
||||
}
|
||||
#endif
|
||||
@ -1,4 +1,5 @@
|
||||
namespace DigitalData.Core.Abstraction.Application.Repository
|
||||
#if NET
|
||||
namespace DigitalData.Core.Abstraction.Application.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the contract for CRUD operations on a repository for entities of type TEntity.
|
||||
@ -61,3 +62,4 @@
|
||||
Task<int> CountAsync(TId id);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -1,4 +1,7 @@
|
||||
namespace DigitalData.Core.Abstraction.Application.Repository
|
||||
#if NETFRAMEWORK
|
||||
using System.Collections.Generic;
|
||||
#endif
|
||||
namespace DigitalData.Core.Abstraction.Application.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines methods for mapping between entities and Data Transfer Objects (DTOs).
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user