Changed the `Id` property in the `Profile` class from `short?` to `long` to support larger values and resolve a type mismatch with the `ProfileId` foreign key in the `RecAction` class.
Removed the `[NotMapped]` attribute from the `Profile` navigation property in `RecAction` as the type mismatch issue has been resolved. Also removed the related TODO comment. These changes improve database schema consistency and integrity.
Added `[Table]` attributes to `Connection`, `Endpoint`, `EndpointAuth`, and `Profile` classes to define database table mappings. Updated `Profile` with schema information.
Introduced a `Profile` navigation property in `RecAction` with a `[ForeignKey]` attribute to establish a relationship with the `Profile` entity. Temporarily marked it as `[NotMapped]` due to a foreign key type mismatch, with a `TODO` to resolve this in the future.
Included `System.ComponentModel.DataAnnotations.Schema` in `using` directives to support these changes.
Added a new "ConnectionStrings" section to the `appsettings.json`
file, including a "Default" connection string for SQL Server.
The connection string specifies the server, database, user
credentials, and options to disable encryption and trust the
server certificate. This change configures database connectivity
for the application.
Enhanced the DeleteRecActionsCommandHandler to include a check
for the existence of records before deletion, throwing a
NotFoundException if none are found. Made the Handle method
asynchronous and added necessary namespace imports for
exception handling and database operations. Added a comment
to suggest updating the DeleteAsync method in the Core library
to return the number of deleted records.
A new HTTP DELETE endpoint has been added to the `RecActionController` class. The endpoint, implemented as the `GetActions` method, accepts a `profileId` as a query parameter and uses the mediator pattern to send a `DeleteRecActionsCommand` with the provided `profileId`.
The method returns an HTTP 204 No Content response upon successful deletion, ensuring a clean separation of concerns and adherence to the CQRS pattern.
The `ActionController` class was removed and replaced with a new `RecActionController` class. The new class retains the same functionality, methods (`Invoke`, `CreateAction`, `CreateFakeAction`), and dependencies as the removed class.
The namespace (`ReC.API.Controllers`) and route attributes remain unchanged. Dependency injection for `IMediator` is preserved. This change is primarily a renaming of the controller to better align with its purpose while maintaining existing behavior.
Refactored the `CreateFakeAction` method in `ActionController`:
- Replaced individual parameters with a strongly-typed `FakeRequest` model for the request body.
- Added `[FromQuery]` attributes for `endpointUri`, `endpointPath`, and `type` to allow query parameter overrides.
- Updated serialization logic for `Body` and `Header` to handle null values more explicitly.
- Adjusted `BodyQuery` and `HeaderQuery` assignments to improve null handling.
Also updated `using` directives to include `ReC.API.Models` and `ReC.Application.RecActions.Commands`.
Introduced a new `FakeRequest` class in the `ReC.API.Models` namespace.
The class includes `Body` and `Header` properties, both of which
are nullable dictionaries with string keys and object values.
These properties are marked as `init`-only to ensure immutability
after initialization. This model is designed to support flexible
handling of request payloads and headers.
Updated the `AddOpenBehaviors` method call in `DependencyInjection.cs` to reflect changes in the `HeaderQueryBehavior` class, which now requires two generic type parameters instead of one. This ensures compatibility with the updated class definition.
Updated HeaderQueryBehavior to support two generic type
parameters, TRequest and TResponse, for improved flexibility.
Replaced the single TRecAction type parameter and Unit return
type with a more generic implementation. Updated where
constraints to reflect the new generic types. Modified the
Handle method signature and logic to align with the updated
generic parameters.
Modified the `AddOpenBehaviors` method in the `DependencyInjection` class to update `BodyQueryBehavior<>` to its two-type parameter version, `BodyQueryBehavior<,>`. The `HeaderQueryBehavior<>` remains unchanged.
Updated BodyQueryBehavior to support a generic request-response
pipeline. Replaced fixed `TRecAction` and `Unit` types with
`TRequest` and `TResponse` generics. Added `where` constraints
for `TRequest` (`RecActionDto`) and `TResponse` (`notnull`).
Updated the `Handle` method signature and return type to align
with the new generics.
The `MediatRLicense` key was removed from `appsettings.json`
and replaced with the `LuckyPennySoftwareLicenseKey`. This
change likely reflects a transition to a new licensing
mechanism. No other modifications were made to the file.
Updated `DtoMappingProfile` and `MappingProfiles` to explicitly inherit from `AutoMapper.Profile` for clarity. Added mapping configurations for `RecActionView` to `RecActionDto` and `CreateOutResCommand` to `OutRes` using `CreateMap` in their respective constructors.
Updated ActionController to support JSON serialization for
request body and headers in the CreateFakeAction method.
Replaced `bodyQuery` with `body` and `header` parameters,
serialized to JSON. Updated `BodyQuery` and added
`HeaderQuery` in `CreateRecActionCommand`. Refactored
endpoint URI construction and improved response handling.
Refactored ActionController to include IMediator dependency
in the constructor. Updated CreateFakeAction method to:
- Set a default value for `endpointUri`.
- Add an optional `endpointPath` parameter and logic to
construct a full URI.
- Include the `Active` property in CreateRecActionCommand.
- Ensure `endpointUri` is non-nullable.
Also added the `System.IO` namespace for potential future use.
Refactor `using` directives in `Program.cs` to include `ReC.API.Middleware` for middleware functionality.
Introduce `ExceptionHandlingMiddleware` to the HTTP request pipeline to handle exceptions globally. Suppress CS0618 warnings for its usage. No changes were made to the existing controller service configuration.
Enhanced the ExceptionHandlingMiddleware to handle
DataIntegrityException explicitly. Added a new `using`
directive for `ReC.Application.Common.Exceptions` to
support this change. When a DataIntegrityException is
caught, the middleware now sets the HTTP status code to
409 Conflict and returns the exception's message.
Also updated the default case to ensure unhandled
exceptions are logged and return a generic error message
with a 500 Internal Server Error status code.
Introduced `ExceptionHandlingMiddleware` to handle exceptions globally, log them, and return appropriate HTTP responses with JSON error messages.
- Added `HandleExceptionAsync` for exception processing.
- Handled `BadRequestException` (400) and `NotFoundException` (404).
- Included default handling for unhandled exceptions (500).
- Marked middleware as `[Obsolete]` with a note to use `DigitalData.Core.Exceptions.Middleware`.
- Added necessary `using` directives and XML documentation.
Updated CreateOutResCommandHandler to use the OutRes entity
instead of the command itself in repository operations. Added
a new using directive for ReC.Domain.Entities. Updated the
CreateOutResCommand class to implement MediatR's IRequest
interface.
The ActionController class was updated to include a new
CreateFakeAction endpoint. This endpoint accepts optional
parameters (endpointUri, type, and bodyQuery) and sends a
CreateRecActionCommand with hardcoded and default values.
The CreateRecActionCommand record was modified to remove
default values for ProfileId, Type, and BodyQuery. These
properties now require explicit initialization, with Type
and BodyQuery marked as non-nullable using the null! syntax.
These changes improve flexibility and add support for
creating "fake" actions via the new endpoint.
Simplified the `Handle` method by removing the `async` modifier
and replacing the `await` call with a direct `return` statement
for `repo.DeleteAsync`. This optimization eliminates the
overhead of creating an async state machine, as no additional
asynchronous operations or logic are performed in the method.
Introduced `DeleteRecActionsCommand` and its handler to enable
deletion of `RecAction` entities based on `ProfileId`. Added
necessary `using` directives and organized the code under the
`ReC.Application.RecActions.Commands` namespace. The handler
uses dependency injection for the repository and performs
asynchronous deletion with cancellation support.
A new HTTP POST endpoint `CreateAction` was added to the
`ActionController` class. This endpoint accepts a
`CreateRecActionCommand` object from the request body, sends
it to the `mediator` for processing, and returns a `201 Created`
response using the `CreatedAtAction` method. This change
enables the creation of actions via HTTP POST requests,
enhancing the controller's functionality.
Expanded RecDbContext to include new DbSet properties for
managing `Connections`, `Endpoints`, `EndpointAuths`,
`Profiles`, and `RecActions`. These additions enable
interaction with corresponding database tables/entities.
Updated the `OnModelCreating` method to ensure proper
configuration of the context. Removed an extraneous
closing brace to maintain proper syntax.
Introduced a new asynchronous `CreateAction` method in the
`ActionController` class to handle HTTP POST requests for
creating "rec actions". The method accepts a `CreateRecActionCommand`
object from the request body, processes it using `mediator.Send`,
and returns a `201 Created` response using `CreatedAtAction`.
Removed unused `using` directives for `DigitalData.Core.Abstraction.Application.Repository` and `ReC.Domain.Entities`. Reordered `using` directives for better organization. Updated the `ProfileId` property in `CreateRecActionCommand` to have a default value of `2`, improving code clarity and reducing the need for explicit initialization.
Introduced a new `MappingProfile` class in the `ReC.Application.RecActions` namespace to define object-to-object mapping configurations using AutoMapper.
The profile maps `CreateRecActionCommand` to `RecAction`, enabling seamless data transformation between these types. Added necessary `using` directives for `ReC.Application.RecActions.Commands` and `ReC.Domain.Entities`.
Replaced `GetOrCreateEndpointCommand` with `ObtainEndpointCommand`
to improve clarity and align with naming conventions. Removed
`GetOrCreateEndpointCommand` and its handler, and introduced
`ObtainEndpointCommand` with equivalent functionality.
Updated `MappingProfile.cs` to map `ObtainEndpointCommand` to
`Endpoint`. Refactored `CreateRecActionCommand.cs` to use the
new `ObtainEndpointCommand` for retrieving or creating `Endpoint`
entities.
These changes ensure consistent naming and maintain the same
behavior while improving code readability.
Renamed `GetOrCreateCommand` to `GetOrCreateEndpointCommand`
to improve clarity and consistency. Removed the old
`GetOrCreateCommand` class and handler, and introduced the
new `GetOrCreateEndpointCommand` class with equivalent
functionality.
Updated `MappingProfile` to reflect the new command name
and adjusted `CreateRecActionCommand` to use the renamed
command. Added the appropriate namespace for the new class
to ensure proper organization.
The `Id` property in the `Endpoint` class was changed from a
nullable `long?` to a non-nullable `long`. This ensures that
the `Id` property is always assigned a value and cannot be
`null`, improving data integrity and aligning with potential
database or application requirements.
Updated `CreateRecActionCommand` to implement `IRequest` for MediatR compatibility. Introduced `CreateRecActionCommandHandler` to process requests, including validation for `EndpointId` and `EndpointUri`. Added logic to fetch or create an endpoint when `EndpointUri` is provided. Updated `EndpointId` property to be mutable. Added necessary `using` directives and adjusted the namespace declaration.
Removed unused `using` directives across files for cleanup. Deleted `CreateEndpointCommand` and `Endpoint` classes as they are no longer needed. Added `GetOrCreateCommand` to handle endpoint retrieval or creation. Updated `MappingProfile` to remove mappings for `CreateEndpointCommand` and ensure proper inheritance from `AutoMapper.Profile`.
Refactored the `GetOrCreateCommand` to simplify the creation
of `Endpoint` entities by delegating the creation logic to
`repo.CreateAsync`.
Added a new `MappingProfile` class using AutoMapper to define
mappings between command objects (`CreateEndpointCommand` and
`GetOrCreateCommand`) and the `Endpoint` entity, improving
code maintainability and reducing boilerplate.
Included necessary `using` directives in `MappingProfile.cs`
to support the new mapping functionality.
Introduced the `CreateEndpointCommand` class as a placeholder for future implementation. Added the `Endpoint` class with properties `Active`, `Description`, and `Uri` to represent endpoint details. Included necessary `using` directives and organized the code under the `ReC.Application.Endpoints.Commands` namespace.
Introduced `GetOrCreateCommandHandler` to handle `GetOrCreateCommand` requests.
The handler checks if an `Endpoint` with the specified `Uri` exists in the repository
and returns it if found. If not, it creates a new `Endpoint`, saves it, and returns
the newly created object. Added necessary `using` directives for repository abstraction
and Entity Framework Core functionality.
Introduced the `GetOrCreateCommand` class in the `ReC.Application.Endpoints.Commands` namespace. This class implements the `IRequest<Endpoint>` interface from MediatR to handle requests for retrieving or creating an `Endpoint`.
Added `Uri` property to the command with an `init` accessor for immutability. Included necessary `using` directives for `MediatR` and `ReC.Domain.Entities`.
The `Guid` property in the `EndpointParam` class was renamed to `Id` to improve code readability and align with naming conventions. The `[Key]` and `[Column("GUID")]` attributes remain unchanged, ensuring the database schema mapping and primary key designation are preserved.
The `EndpointId` property in the `CreateRecActionCommand` class
was updated from a non-nullable `long` to a nullable `long?`
to allow it to hold `null` values.
Additionally, a new nullable `string?` property `EndpointUri`
was introduced to support specifying an optional endpoint URI.
Introduced a new namespace `ReC.Application.RecActions.Commands`
and added the `CreateRecActionCommand` record. This record
includes properties such as `ProfileId`, `Active`, `EndpointId`,
`Type`, `HeaderQuery`, and `BodyQuery` to encapsulate the
necessary data for creating RecActions. Default values were
provided for `Active`, `Type`, and `BodyQuery` to streamline
initialization.
Introduced a new `SqlConnection` property in the `RecAction` class, marked with the `[ForeignKey("SqlConnectionId")]` attribute. This establishes a foreign key relationship with the `SqlConnectionId` property, enabling ORM navigation between `RecAction` and the `Connection` entity.
The RecAction class in RecAction.cs now includes a new
navigation property, EndpointAuth, which is linked to the
EndpointAuthId column via the [ForeignKey] attribute. This
enhances the entity relationship by associating the
EndpointAuthId property with the EndpointAuth entity.
Enhanced the `RecAction` class by adding a navigation property
(`Endpoint`) to represent the relationship with the `Endpoint`
entity. Annotated the `Endpoint` property with the
`[ForeignKey("EndpointId")]` attribute to establish the foreign
key mapping. This improves the data model by explicitly defining
the relationship between `RecAction` and `Endpoint`.
Introduced a `Profile` navigation property to the `RecAction` class, annotated with `[ForeignKey("ProfileId")]`. This establishes a foreign key relationship between the `ProfileId` property and the `Profile` entity, enabling ORM navigation between `RecAction` and `Profile`.
The `ProfileName` property in the `Profile` class was renamed to `Name` to improve clarity or consistency. The `[Column("PROFILE_NAME")]` attribute remains unchanged, ensuring the database column mapping is unaffected.
Introduced a new `Profile` class in the `ReC.Domain.Entities` namespace to represent the `TBREC_CFG_PROFILE` table in the `dbo` schema.
- Added Entity Framework annotations to map properties to database columns.
- Defined properties for fields such as `Id`, `Active`, `Type`, `ProfileName`, `Description`, and others.
- Used nullable types for all properties to allow null values.
- Marked `Id` as the primary key with auto-generation enabled.
This change enables ORM support for managing profile-related data.
Introduce a new `Connection` class in the `ReC.Domain.Entities` namespace.
The class is mapped to the `TBDD_CONNECTION` database table and includes
properties for various columns such as `Id`, `Bezeichnung`, `SqlProvider`,
and others. Attributes like `[Key]`, `[Column]`, and `[DatabaseGenerated]`
are used for database mapping. Nullable types are used for all properties.
Added necessary `using` directives for annotations and schema mapping.
Introduced the `EndpointAuth` class in the `ReC.Domain.Entities` namespace to represent the `TBREC_CFG_ENDPOINT_AUTH` database table.
- Added Entity Framework annotations for table and column mappings.
- Defined properties for all table columns, including `Id`, `Active`, `Description`, `Type`, `ApiKey`, `ApiValue`, `ApiKeyAddTo`, `Token`, `Username`, `Password`, `Domain`, `Workstation`, `AddedWho`, `AddedWhen`, `ChangedWho`, and `ChangedWhen`.
- Configured `Id` as the primary key with auto-generated values.
Renamed the property `Guid` to `Id` in the `RecAction` class
to improve clarity and align with naming conventions or
database schema updates. No other changes were made to
the file.
Introduced a new `Endpoint` class in the `ReC.Domain.Entities` namespace to represent the `TBREC_CFG_ENDPOINT` database table.
- Added Entity Framework annotations to map properties to database columns.
- Defined properties for `Id`, `Active`, `Description`, `Uri`, `AddedWho`, `AddedWhen`, `ChangedWho`, and `ChangedWhen`.
- Configured `Id` as the primary key with auto-generated values.