Implemented HTTP PUT request handling in the
InvokeRecActionCommandHandler class. Previously, the PUT case
only had a placeholder comment. Now, it uses
http.PutAsync to send a PUT request to the specified
action.EndpointUri, aligning it with the existing POST
request handling.
Previously, the handling of HTTP POST requests in the
InvokeRecActionCommandHandler class was not implemented.
This commit adds the necessary code to handle POST requests
by using the http.PostAsync method. The POST request is sent
to the specified action.EndpointUri with null content and a
cancellation token. This change ensures that POST operations
are now properly executed within the command handler.
Updated the HTTP request handling logic within the action loop to dynamically construct requests based on the `RestType` and `EndpointUri` of each action. Expanded the switch statement to handle GET, POST, PUT, and DELETE methods, allowing for specific logic to be implemented for each. Removed the hardcoded URL and response content retrieval, indicating potential refactoring of response handling. The default case continues to throw a `BadRequestException` for unsupported REST types.
Convert RestType to uppercase in the switch statement to
ensure case-insensitive matching of REST types. This change
handles variations like "get", "Get", and "GET" consistently.
Additionally, use the null-conditional operator to prevent
NullReferenceException when RestType is null.
Refactor `using` directives in `InvokeRecActionCommand.cs` to include `DigitalData.Core.Exceptions` and `System.Net.Http`.
Implement logic in `InvokeRecActionCommandHandler` to handle different REST actions using `HttpClient`. Introduce a `switch` statement to process "GET", "POST", "PUT", and "DELETE" actions, with a `BadRequestException` for unsupported types. Read HTTP response content asynchronously.
Updated `using` directives to include MediatR and related namespaces. Refactored `ActionController` to use constructor injection for `IMediator`. Modified the `Invoke` method to be asynchronous and replaced the placeholder `NotImplementedException` with a call to `mediator.InvokeRecAction(profileId)`. The method now returns an `Accepted` HTTP response to indicate successful request processing.
Introduce a new static class `InvokeRecActionCommandExtensions`
to extend the `ISender` interface with the `InvokeRecAction`
method. This method simplifies the invocation of
`InvokeRecActionCommand` by allowing callers to pass only the
`profileId`, internally creating and sending the command.
Replaced the `InvokeRecActionQuery` class with the `InvokeRecActionCommand` class to better align with CQRS semantics. The new class retains the same `ProfileId` property and implements the `IRequest` interface. Updated the namespace to remain consistent.
Introduced the `InvokeRecActionQuery` class in the `ReC.Application.RecActions.Commands` namespace to implement the Mediator pattern using the MediatR library.
- Added `using MediatR;` directive to include the library.
- Implemented `IRequest` interface in the new class.
- Added `ProfileId` property with `init` accessor for immutability.
- Organized the code under a new namespace for better structure.
Renamed `AddInfrastructureServices` to `AddRecInfrastructure`
in both generic and non-generic forms to standardize naming
and improve clarity. Updated `Program.cs` to use the new
method, adding database context configuration with a
connection string from the app's configuration.
Added a constraint to `AddRecInfrastructure<TRecDbContext>`
requiring `TRecDbContext` to inherit from `RecDbContext`.
Refactored the method to register entities from the assembly
containing `RecAction`. Removed the old
`AddInfrastructureServices` method entirely.
Added `AddRecServices` and `AddInfrastructureServices` to `Program.cs` with necessary configurations. Updated `ReC.API.csproj` to include project references to `ReC.Application` and `ReC.Infrastructure`, and fixed an encoding issue by adding a BOM. Modified `appsettings.json` to include `MediatRLicense` and adjusted `AllowedHosts` format. Ensured `TargetFramework` and other project properties remain unchanged.
Updated the `LuckyPennySoftwareLicenseKey` property in the
`ConfigurationOptions` class to allow null values by changing
it from a non-nullable string with a default value of an empty
string to a nullable string (`string?`). This change enables
explicit representation of the absence of a license key using
`null` instead of an empty string.
Introduced a new `DependencyInjection` class in the `ReC.Application` namespace to streamline service registration.
- Added `AddRecServices` extension method for `IServiceCollection` to configure AutoMapper and MediatR with assembly scanning.
- Included `ConfigurationOptions` class to allow configuration of a `LuckyPennySoftwareLicenseKey`.
- Added `using` directives for `Microsoft.Extensions.DependencyInjection` and `System.Reflection` to support dependency injection and assembly scanning.
Added `AutoMapper` and `MediatR` NuGet packages to the
`ReC.Application.csproj` file to include these libraries as
dependencies.
Created a `DtoMappingProfile` class in the `ReC.Application.Dto`
namespace to define a mapping configuration between the `RecAction`
entity and the `RecActionDto` data transfer object using `AutoMapper`.
Included necessary `using` directives for `AutoMapper` and
`ReC.Domain.Entities` in the `DtoMappingProfile.cs` file to enable
the mapping functionality.
These changes improve maintainability by automating object-to-object
mapping and prepare the project for potential use of the mediator
pattern with `MediatR`.
Added the `MediatR` NuGet package (v13.1.0) to enable the mediator pattern. Updated `ReC.Application.csproj` to include a project reference to `ReC.Domain`.
Introduced `RecActionDto` as a Data Transfer Object (DTO) for representing "RecAction" details, including properties for endpoints, authentication, and SQL connections.
Added `ReadRecActionQuery` to handle queries for retrieving `RecActionDto` objects, leveraging MediatR. This query filters results based on `ProfileId`.
Added `Microsoft.EntityFrameworkCore` and `ReC.Infrastructure` namespaces to `Program.cs` to enable EF Core functionality and infrastructure services. Configured the database context with a connection string from the app's configuration and added error handling for missing connection strings.
Updated `ReC.API.csproj` to include the `Microsoft.EntityFrameworkCore.SqlServer` NuGet package (v9.0.11) for SQL Server support. Added a project reference to `ReC.Infrastructure` to enable the API project to use the infrastructure layer.
Updated AddInfrastructureServices to support a generic
TRecDbContext type parameter, enabling the use of custom
DbContext types. Modified AddDbContext and AddDbRepository
to use the generic TRecDbContext type. Added an overload
of AddInfrastructureServices that defaults to RecDbContext
for backward compatibility. These changes enhance flexibility
and reusability while maintaining compatibility with existing
implementations.
Added `DigitalData.Core.Infrastructure` dependency and updated the `DependencyInjection` class to include `services.AddDbRepository` for dynamic repository registration from the `RecAction` assembly. Updated `ReC.Infrastructure.csproj` to include the new package reference. Improved dependency injection setup for better repository management.
Introduced a `DependencyInjection` class with an extension
method `AddInfrastructureServices` to register `RecDbContext`
using configurable `DbContextOptions`. Added a `ConfigurationOptions`
class to encapsulate `DbContext` configuration.
Validated that `DbContextOptionsAction` is provided before
registration. Updated `ReC.Infrastructure.csproj` to include
`Microsoft.Extensions.Configuration.Abstractions` for enhanced
configuration support. Added necessary `using` directives.
Replaced the `Action` class with a new `RecAction` class to represent the `VWREC_ACTION` database view. The `RecAction` class retains the same properties and annotations as the removed `Action` class, ensuring compatibility with the database schema.
Updated `RecDbContext` to use `RecAction`:
- Replaced `DbSet<Domain.Entities.Action>` with `DbSet<RecAction>`.
- Updated the `OnModelCreating` configuration to use `RecAction`.
This refactor improves clarity, aligns with naming conventions, and prepares the codebase for future changes.
Added the `Microsoft.EntityFrameworkCore` NuGet package to the
`ReC.Infrastructure` project to enable database functionality.
Introduced `RecDbContext` with `DbSet` properties for `EndpointParam`,
`Action`, and `OutRes` entities. Configured `Action` as a keyless
entity in `OnModelCreating`. Added a project reference to
`ReC.Domain` to use domain entities in the infrastructure layer.
The `Trigger` method in the `ActionController` class was renamed to `Invoke`. This change updates the HTTP POST endpoint that accepts a `profileId` as a route parameter. The method's functionality remains unchanged, as it still throws a `NotImplementedException`.
A new `OutRes` class was added to represent the `TBREC_OUT_RESULT` table in the `dbo` schema. The class includes properties for `Id`, `ActionId`, `ResultHeader`, `ResultBody`, `AddedWho`, `AddedWhen`, `ChangedWho`, and `ChangedWhen`, all mapped to corresponding database columns using data annotations. The `System.ComponentModel.DataAnnotations` and `System.ComponentModel.DataAnnotations.Schema` namespaces were imported to support this configuration.
Renamed the class `VwRecAction` to `Action` to simplify the name
and better align with naming conventions. The `[Table]` attribute
mapping to `VWREC_ACTION` in the `dbo` schema remains unchanged.
Class properties such as `ActionId` and `ProfileId` are unaffected
by this change.
Introduced the `EndpointParam` class to represent the `TBREC_CFG_ENDPOINT_PARAMS` table in the database.
- Added `using` directives for data annotations and table mapping.
- Defined properties to map to table columns, all nullable for flexibility.
- Annotated the class with `[Table]` and properties with `[Column]` attributes.
- Marked `Guid` as the primary key using the `[Key]` attribute.
- Documented the class with a summary explaining its purpose and design.
This change facilitates ORM integration and ensures schema flexibility.
Introduced the `VwRecAction` class to represent the `VWREC_ACTION`
database view. The class is annotated with `[Table]` and `[Column]`
attributes for schema mapping and includes nullable properties to
handle potential schema changes gracefully. Added `using` directives
for data annotations and schema mapping. Documented the class to
explain its purpose and design decisions, ensuring flexibility and
resilience against database schema evolution.
Updated `ReC.API.csproj` to include `Swashbuckle.AspNetCore` (v6.6.2) for Swagger/OpenAPI documentation. Removed an unused `<ItemGroup>` referencing the `Controllers\` folder.
Added a new `ActionController` with a `[Route("api/[controller]")]` and `[ApiController]` attributes. Introduced a `Trigger` HTTP POST endpoint that accepts a `profileId` parameter. The method is currently unimplemented and throws a `NotImplementedException`.
A new project, ReC.Client, has been added to the solution file (ReC.sln).
The project supports two target frameworks: net462 and net8.0.
Build configurations for Debug and Release have been added, and the
project has been nested under the same parent as other projects.
The ReC.Client.csproj file uses the Microsoft.NET.Sdk SDK and includes
conditional properties for frameworks other than net462, enabling
implicit global usings and nullable reference types.
A new project, `ReC.Application`, has been added to the solution (`ReC.sln`).
The project file (`ReC.Application.csproj`) targets .NET 8.0, enables implicit
global usings, and enables nullable reference types.
The solution file has been updated to include the new project, its build
configurations, and its nesting under the `src` folder.
A new project, `ReC.Infrastructure`, has been added to the solution.
The project is configured to target `.NET 8.0` and includes modern
features such as implicit global usings and nullable reference types.
It has been integrated into the solution's build configurations
(Debug/Release for Any CPU) and nested under the `src` folder.
A new project, `ReC.Domain`, has been added to the solution.
The project is included in `ReC.sln` with build configurations
for `Debug|Any CPU` and `Release|Any CPU`. It is nested under
the `src` folder in the solution structure.
The `ReC.Domain.csproj` file targets .NET 8.0, uses the
`Microsoft.NET.Sdk` SDK, and enables modern C# features such
as implicit `using` directives and nullable reference types.
Initialized the ASP.NET Core application in `Program.cs` with
services for controllers, Swagger/OpenAPI, and middleware
for HTTPS redirection and authorization.
Added `launchSettings.json` to configure application launch
profiles for HTTP, HTTPS, and IIS Express environments.
Updated `ReC.API.csproj` to target .NET 8.0, enable nullable
reference types, and include the `Swashbuckle.AspNetCore`
package for Swagger support.
Added `appsettings.json` and `appsettings.Development.json`
for logging and environment-specific configurations.
Reorganized the solution structure in `ReC.sln` by moving
the `ReC.API` project under a `src` folder and updating
the `NestedProjects` section.
Set up a new ASP.NET Core Web API project named `ReC.API` targeting .NET 8.0.
- Added `ReC.sln` solution file with Debug and Release configurations.
- Configured logging settings in `appsettings.json` and `appsettings.Development.json`.
- Created `Program.cs` to bootstrap the application with controllers, Swagger, and middleware.
- Defined project structure in `ReC.API.csproj`, including Swagger dependency and nullable reference types.
- Added `launchSettings.json` with profiles for `http`, `https`, and `IIS Express`.