The `Get` method in the `RecActionController` class was updated to use the `[FromQuery]` attribute for the `invoked` parameter. This change ensures that the parameter value is explicitly bound from the query string of the HTTP request, improving clarity and alignment with expected usage.
Updated the Get method in RecActionController to include a
new optional parameter, `invoked`, with a default value of
`false`. Updated XML documentation to reflect this change.
Modified the `ReadRecActionQuery` initialization to pass the
`invoked` parameter. Removed the previous method signature
that only accepted a `CancellationToken`.
Updated `InvokeBatchRecActionsCommandExtensions` to filter actions with `Invoked = false` using a lambda in `ToReadQuery`.
Refactored `ReadRecActionQueryBase` to remove the `Invoked` property and updated `ToReadQuery` to accept a delegate for external query modifications.
Moved the `Invoked` property to `ReadRecActionQuery` and added a parameterless constructor.
These changes improve flexibility and enable dynamic query customization.
Introduced a nullable `Invoked` property in `ReadRecActionQueryBase`
to enable conditional filtering of actions based on `Root.OutRes`.
Added a `ToReadQuery` method for easier query conversion.
Refactored `ReadRecActionQueryHandler` to apply dynamic filtering
based on the `Invoked` property:
- `true`: Filters actions with non-null `Root.OutRes`.
- `false`: Filters actions with null `Root.OutRes`.
- `null`: No additional filtering applied.
Replaced hardcoded filtering logic with the new dynamic approach.
Renamed the `RootAction` property to `Root` in the `RecActionView` class to improve clarity and align with naming conventions. Updated the `ReadRecActionQueryHandler` class to reference the renamed property in its LINQ query, ensuring consistency between the data model and query logic.
Enhanced the `Handle` method in `ReadRecActionQueryHandler`
to include an additional filtering condition when querying
the repository. The query now filters actions where
`RootAction.OutRes` is not null, in addition to matching
the `ProfileId`. This ensures that only relevant actions
with a valid `OutRes` are included in the result set.
Introduced a new `OutRes` navigation property in the `RecAction`
class to establish a one-to-one relationship with the `OutRes`
entity. Updated `RecDbContext` to configure this relationship
using the Fluent API. The `OutRes` entity references its
associated `RecAction` via the `Action` navigation property,
with `ActionId` as the foreign key.
Introduced a new nullable `RootAction` property in the `RecActionView` class. This property is decorated with the `[ForeignKey("Id")]` attribute, establishing a foreign key relationship with the `Id` property. This change enables the `RecActionView` entity to reference an optional `RecAction` entity, enhancing the data model and supporting entity relationships.
Introduced a `Profile` navigation property in the `RecActionView` class, linked to the `ProfileId` column using the `[ForeignKey]` attribute. The `Profile` property is nullable to support cases where no related `Profile` exists.
Added XML documentation to `OutResController` methods for clarity.
Introduced `ResultType` enum to specify result parts (Full, Header, Body).
Enhanced `Get` methods to support fake/test profiles and actions.
Added `[ProducesResponseType(StatusCodes.Status200OK)]` for explicit
response status codes. Updated `Get` overloads for various scenarios.
Utilized `config.GetFakeProfileId()` for dynamic fake profile handling.
Updated `Get` methods in `OutResController` to include a
`CancellationToken` parameter, enabling support for request
cancellation during asynchronous operations. Updated all
`mediator.Send` calls to propagate the `CancellationToken`.
Simplified the "fake/{actionId}" route by removing the explicit
assignment of `HttpContext.Response.ContentType` for non-
`ResultType.Full` cases.
Added new endpoints for invoking, retrieving, creating, and deleting
RecActions, including support for both specific and fake/test profiles.
Endpoints include:
- `Invoke` for batch invocation of RecActions.
- `Get` for retrieving RecActions by profile.
- `CreateAction` for creating new RecActions.
- `CreateFakeAction` for creating test RecActions.
- `Delete` for deleting RecActions by profile.
Enhanced all endpoints with XML documentation for clarity and added
`ProducesResponseType` attributes to specify expected HTTP status codes.
Replaced the `catch` block in the `JsonExtensions` class to suppress exceptions silently instead of returning the original string when JSON deserialization fails. The `return str;` statement was moved outside the `try-catch` block, making it the default return value. This change removes explicit handling of invalid JSON inputs and may impact debugging.
Refactored `ConfigExtensions.cs` to move `ConfigurationExtensions`
to the `ReC.API.Extensions` namespace and re-added the
`GetFakeProfileId` method. Introduced `JsonExtensions.cs` with
a `JsonToDynamic` method for recursive JSON deserialization,
simplifying nested JSON handling. Updated `OutResController.cs`
and `RecActionController.cs` to use the new `JsonToDynamic`
method, improving code readability and reducing duplication.
Overall, modularized and cleaned up code for better maintainability.
Introduced a new `HttpGet` endpoint `fake/{actionId}` in the
`OutResController` to support fetching OutRes data filtered
by `actionId` and an optional `resultType` parameter.
Added logic to handle different `resultType` values (`Full`,
`Header`, `Body`) and return the appropriate part of the
result. Updated response `ContentType` for non-`Full` results
and ensured null-safe handling for `Body` and `Header`.
Included a new `ResultType` enum and added necessary `using`
directives for the new functionality.
Reordered using directives in DtoMappingProfile.cs.
Added AutoMapper mapping for OutRes to OutResDto.
Modified ReadOutResQuery to return IEnumerable<OutResDto>.
Updated ReadOutResHandler to handle collection results:
- Changed Handle method to return IEnumerable<OutResDto>.
- Updated mapper.Map to map to a collection of OutResDto.
Updated `InvokeRecActionsCommandHandler` to use `IServiceScopeFactory` for creating scoped services. Replaced direct `IHttpClientFactory` usage with dynamic resolution of `ISender` within a service scope. Improved dependency injection adherence and ensured proper scoping of services. Added `Microsoft.Extensions.DependencyInjection` to `using` directives.
Replaced hardcoded FakeProfileId with a dynamic value retrieved
from the configuration using a new GetFakeProfileId extension
method. Updated OutResController and RecActionController to
inject IConfiguration and use the new method. Added a new
HttpGet endpoint in OutResController for fake profile queries.
Modified appsettings.json to include a FakeProfileId setting
with a default value of 2. Introduced ConfigurationExtensions
to centralize configuration access logic, improving code
maintainability and flexibility.
The validation rule in the `ReadOutResQueryValidator` class was updated to include a `WithName("Identifier")` call. This assigns a name ("Identifier") to the rule, improving the clarity and usability of validation error messages, especially in scenarios where multiple rules are applied and need to be distinguished.
Added a new asynchronous `Get` method to the `OutResController`
class in the `ReC.API.Controllers` namespace. This method handles
HTTP GET requests, accepts a `ReadOutResQuery` object as a query
parameter, and uses the `mediator` to process the query. The
result is returned in an HTTP 200 OK response. This change
enables retrieval of resources or data based on the provided
query parameters.
Updated `using` directives to include `DigitalData.Core.Exceptions` for custom exception handling. Renamed `dtos` to `resList` for clarity. Added a check to throw `NotFoundException` when no results are found in the query. Updated the return logic to ensure mapping occurs only when results exist. These changes enhance error handling and improve code robustness.
Introduced a new `OutResController` in the `ReC.API.Controllers`
namespace to handle API requests. The controller uses MediatR
for request handling and is decorated with `[ApiController]`
and `[Route("api/[controller]")]` attributes.
Added a `Get` method to process `ReadOutResQuery` objects
from query parameters and return the result via MediatR.
Included necessary `using` directives for dependencies.
Enhanced `ReadOutResHandler` to support filtering by `ProfileId`
when querying `OutRes` entities. This was implemented by adding
a condition to filter results based on the `ProfileId` of the
associated `Action`.
Updated the `OutRes` class to include a navigation property
`Action`, annotated with `[ForeignKey]` to link it to the
`ActionId` column. This establishes a relationship between
`OutRes` and `RecAction`, improving data access and maintainability.
Refactored `ReadOutResQuery` to a record type implementing
`IRequest<OutResDto>` for MediatR. Introduced `ReadOutResHandler`
to handle the query, leveraging `IRepository` and `IMapper` for
database access and mapping. Added support for filtering by
`ActionId` and asynchronous query execution. Streamlined design
by moving `ProfileId` and `ActionId` to immutable `init`
properties in the record.
Refactored `ExceptionHandlingMiddleware` to use `ValidationProblemDetails` for structured and consistent error responses. Marked the middleware as obsolete with a recommendation to use `DigitalData.Core.Exceptions.Middleware`. Updated exception handling logic to replace error message strings with detailed problem descriptions, including titles and details for each exception type. Improved the default case for unhandled exceptions with a user-friendly message. Enhanced response serialization using `WriteAsJsonAsync`.
Updated `ExceptionHandlingMiddleware` to enhance error handling:
- Added `Microsoft.AspNetCore.Mvc` and `System.Text.Json` for structured JSON responses.
- Made `message` nullable to handle cases without explicit messages.
- Refactored `ValidationException` handling:
- Changed HTTP status code from 422 to 400.
- Grouped validation errors by property and returned them in a `ValidationProblemDetails` object.
- Conditionally wrote `message` to the response only if not null.
- Improved structure and clarity of validation error responses.
Enhanced the `ExceptionHandlingMiddleware` to handle
`ValidationException` from the `FluentValidation` library.
Set HTTP status code to 422 (Unprocessable Entity) for
validation errors and constructed error messages by
aggregating validation error details. Improved error
response clarity for validation-related issues.
Introduced a validation pipeline using FluentValidation and
MediatR to enhance request validation. Added the following:
- Registered FluentValidation and MediatR dependencies in
`ReC.Application.csproj`.
- Updated `DependencyInjection.cs` to register validators
and MediatR behaviors, including `ValidationBehavior<,>`.
- Added `ValidationBehavior<TRequest, TResponse>` to handle
request validation in the MediatR pipeline.
- Created `ReadOutResQueryValidator` to enforce validation
rules for `ReadOutResQuery`.
- Refactored namespaces and imports for better organization.
These changes improve extensibility, maintainability, and
separation of concerns in the application.
Changed the `ProfileId` and `ActionId` properties in the
`ReadOutResQuery` class from non-nullable `long` to nullable
`long?`. This allows these properties to hold `null` values,
making them optional for scenarios where they are not always
required or applicable.
Added a new `OutResDto` record in the `ReC.Application.Common.Dto` namespace to represent output result data with properties like `Id`, `ActionId`, `Header`, `Body`, and audit fields.
Added a new `ReadOutResQuery` class in the `ReC.Application.OutResults.Queries` namespace to facilitate querying output results based on `ProfileId` and `ActionId`.
Reordered `using` directives for clarity and added `ReC.Domain.Entities`.
Added a `TODO` comment to indicate that `AddedWho` should be injected from the current host/user context.
Updated `CreateMap` in `MappingProfiles` to set `AddedWhen` to `DateTime.UtcNow` and `AddedWho` to the hardcoded value `"ReC.API"`.
Added a new HTTP POST endpoint `invoke/fake` in `RecActionController`
to invoke batch actions with a fake profile ID. Updated the `profileId`
parameter type in the `InvokeBatchRecAction` extension method from
`int` to `long` to support larger profile IDs. These changes improve
flexibility and introduce a new endpoint for specific use cases.
- Introduced `FakeProfileId` constant to replace hardcoded values.
- Added `HttpGet` endpoint `api/[controller]/fake` to retrieve data using `FakeProfileId`.
- Added `HttpPost` endpoint `api/[controller]/invoke/{profileId}` for batch actions.
- Updated `CreateAction` and `Delete` methods to use `FakeProfileId`.
- Added `HttpDelete` endpoint `api/[controller]/fake` to delete actions using `FakeProfileId`.
- Improved code maintainability by centralizing the fake profile ID and adding dedicated endpoints.
The `EndpointAuthId` property in the object initialization
within the `RecActionController` class was updated from `1`
to `4`. This change likely reflects an update to the
authentication configuration or a shift to a different
endpoint authorization identifier.
A new HTTP DELETE endpoint has been added to the
`RecActionController` class, accessible via the `"fake"` route.
The `Delete` method is asynchronous and uses the `mediator.Send`
method to execute a `DeleteRecActionsCommand` with a hardcoded
`ProfileId` value of `2`. The method returns an HTTP 204 No
Content response. This endpoint appears to be intended for
testing or placeholder purposes.
Introduced a new `EndpointAuthId` property in `RecActionController` and `CreateRecActionCommand` to enable handling of endpoint authentication. Updated the `RecActionController` to initialize `EndpointAuthId` with a default value of `1`. Modified the `CreateRecActionCommand` record to include a nullable `EndpointAuthId` property of type `long?`, allowing optional specification of authentication details.
A new `Sequence` property of type `byte` was added to the
`CreateRecActionCommand` record. It is initialized with a
default value of `1` and includes a `set` accessor, making
it mutable. This property allows the record to store or
manipulate sequence-related information, enhancing its
functionality.
Updated the `MappingProfile` class to include custom mappings for the `CreateRecActionCommand` to `RecAction` transformation:
- Set `Active` to `true` by default.
- Set `AddedWhen` to the current UTC time.
- Set `AddedWho` to `"ReC.API"` as a placeholder.
Added a `TODO` comment to replace the hardcoded `AddedWho` value with dynamic injection from the current host/user context.
Updated `CreateRecActionCommandHandler` to include a repository
dependency (`IRepository<RecAction>`) for persisting data. Added
a call to `repo.CreateAsync` in the `Handle` method to save the
command request. Updated `using` directives to include necessary
dependencies (`AutoMapper`, `DigitalData.Core.Abstraction.Application.Repository`,
and `ReC.Domain.Entities`). Validation logic for `EndpointId` or
`EndpointUri` remains unchanged.
Refactored the `RecActionController` to improve structure and
readability by introducing a `#region CRUD` section. Updated
the `HttpPost` route for invoking actions to `"invoke/{profileId}"`.
Added a new `CreateAction` method to handle action creation
and renamed the `HttpDelete` method from `GetActions` to
`Delete` for clarity. Introduced the `Invoke` method for batch
action invocation. Improved overall code organization and
maintainability.
Added a TODO comment to update `AddedWho` to be injected
from the current host/user context. Configured `AddedWhen`
to use the current UTC time (`DateTime.UtcNow`) and set
`AddedWho` to the string `"ReC.API"`.
Updated the `MappingProfile` class to configure the mapping
between `ObtainEndpointCommand` and `Endpoint` to explicitly
set the `Active` property of `Endpoint` to `true` using the
`ForMember` method. This ensures that the `Active` property
is initialized to `true` during the mapping process, aligning
with the intended default behavior for new `Endpoint` objects.
The conditional check in the `Handle` method of the
`ReadRecActionQueryHandler` class was updated. Previously, the code
threw a `NotFoundException` if the `actions` list was not empty
(`actions.Count != 0`). This logic was inverted to throw the exception
when the `actions` list is empty (`actions.Count == 0`).
This change ensures the exception is thrown only when no actions are
found for the given profile, aligning with the intended behavior
described in the exception message.
Updated `AddRecInfrastructure` to improve DbContext setup:
- Renamed parameters for clarity (`dbContextOpt` to `opt`).
- Renamed `connectionString` to `cnnStr` for consistency.
- Added `LogTo` for SQL query logging at `Trace` level.
- Enabled `EnableSensitiveDataLogging` for debugging.
- Enabled `EnableDetailedErrors` for detailed error messages.
Added advanced logging and debugging capabilities to the
DbContext configuration in `AddRecInfrastructure`:
- Integrated `ILogger<RecDbContext>` for logging.
- Enabled SQL query logging with `LogTo` at `Trace` level.
- Enabled sensitive data logging for debugging purposes.
- Enabled detailed error messages for better diagnostics.
Updated `ConfigureDbContext` to accept `IServiceProvider`, enabling dependency injection during database context setup. Modified `DependencyInjection.cs` to align with this change by updating `DbContextOptionsAction` and its related method signature.
Removed unused `System.IO` and `System.Text.Json` namespaces from `RecActionController.cs` to improve code cleanliness.
Updated `CreateAction`, `CreateFakeAction`, and `GetActions`
methods in `RecActionController` to include a `CancellationToken`
parameter. This enables handling of cancellation requests during
asynchronous operations. Updated `mediator.Send` calls to pass
the `CancellationToken`, improving responsiveness and resource
management.
Updated the `Invoke` method in `RecActionController` to accept a `CancellationToken` parameter, enabling cancellation handling during execution. Modified the `InvokeBatchRecAction` extension method in `InvokeBatchRecActionsCommandExtensions` to propagate the `CancellationToken` to the `sender.Send` method, ensuring cancellation support for batch action commands.
The `Get` method in `RecActionController` was updated to include a `CancellationToken` parameter, enabling support for operation cancellation. The `mediator.Send` call was modified to pass the token. No changes were made to the `Invoke` method or other unrelated parts of the class.
Added a new Get endpoint to RecActionController to fetch data
based on profileId using ReadRecActionQuery. Updated
ReadRecActionQuery to support long ProfileId, added a
parameterless constructor, and refactored its structure.
Adjusted ReadRecActionQueryHandler to align with these changes.