Commit Graph

269 Commits

Author SHA1 Message Date
Developer 02
88cb1dc16a Handle SqlException in UpdateObjectProcedureHandler
Wrap stored procedure execution in try-catch to handle SqlException.
Throw BadRequestException for configured SQL error numbers.
Update constructor to accept SqlExceptionOptions.
Add necessary using directives for new exception handling.
2026-01-22 01:54:07 +01:00
Developer 02
8d6a09213e Simplify BadRequestException error message on insert failure
Replaced the detailed error message for insert failures with only the original exception message from SqlException, removing extra guidance about referenced entities.
2026-01-22 01:53:55 +01:00
Developer 02
54f412ced2 Improve error handling in DeleteObjectProcedureHandler
Refactored DeleteObjectProcedureHandler to inject SqlExceptionOptions and wrap stored procedure execution in a try-catch block. Added logic to throw custom exceptions (DeleteObjectFailedException, BadRequestException) based on result codes and SQL exception numbers, enhancing robustness and configurability of error handling.
2026-01-22 01:53:40 +01:00
Developer 02
51b9c62188 Add SqlException config options and update dependencies
Added ConfigureSqlException methods to DependencyInjection for flexible SQL exception handling configuration. Updated RecApplicationTestBase to use new options. Bumped DigitalData.Core.Exceptions to v1.1.1.
2026-01-22 01:49:59 +01:00
Developer 02
bb5525778d Improve error handling in InsertObjectProcedureHandler
Wrap SQL execution in try-catch and inject SqlExceptionOptions.
Throw BadRequestException with a clear message when insert fails due to missing referenced entities, based on SqlException number. Other SQL exceptions are rethrown. This provides better feedback for foreign key/reference errors.
2026-01-22 01:49:13 +01:00
Developer 02
22bb585f60 Refactor SQL exception handling and config structure
Simplify SQL exception tracking by replacing error message mappings
with a list of relevant error numbers in appsettings.json. Remove
custom error message logic and related classes, introducing
SqlExceptionOptions to hold tracked error codes.
2026-01-22 01:45:50 +01:00
Developer 02
ed7237c8dd Add SqlExceptionTranslator config and options class
Introduce SqlExceptionTranslator section in appsettings.json to map common SQL error codes to user-friendly messages. Add SqlExceptionTranslatorOptions class to manage error code/message mapping and support configuration binding.
2026-01-22 01:13:02 +01:00
Developer 02
f71bcf37e9 Add SqlExceptionTranslator for custom SQL error handling
Introduced SqlExceptionTranslator and ISqlExceptionTranslator to translate SQL exceptions into user-friendly error messages for bad request scenarios. Uses configurable options to identify relevant error numbers and format messages with templates.
2026-01-22 00:34:35 +01:00
304490d661 Add explicit @RC handling in SQL for delete/update procs
Updated DeleteObjectProcedureHandler and UpdateObjectProcedureHandler to declare, initialize, and select the @RC variable in their SQL command strings. This ensures the stored procedure return code is explicitly captured and returned by the query.
2026-01-20 15:39:54 +01:00
383932e7e7 Remove [Table] attributes from DTO classes
Removed explicit table mapping attributes from EndpointAuthDto, ProfileDto, and RecActionDto to decouple DTOs from database schema definitions.
2026-01-16 13:17:44 +01:00
4895b9c8f8 Refactor: move OutResults to Results namespace
Refactored all "Result" related command and query classes from ReC.Application.OutResults to ReC.Application.Results. Updated all relevant using statements and reorganized files accordingly. No functional changes; this improves project structure and clarity.
2026-01-16 11:13:06 +01:00
36fe78e152 Remove obsolete CreateResultViewCommand and handler
Deleted the CreateResultViewCommand.cs file, including the obsolete CreateResultViewCommand and CreateResultViewCommandHandler classes. These were previously used for creating ResultView entities, but are now replaced by related procedures or views. All associated code and using directives have been removed.
2026-01-16 11:09:02 +01:00
6a24719342 Remove obsolete MappingProfile classes from Endpoints/RecActions
Removed AutoMapper MappingProfile classes from ReC.Application.Endpoints and ReC.Application.RecActions. These profiles mapped command objects to DTOs with default values. The change reflects a move toward using procedures or views for these mappings.
2026-01-16 10:40:28 +01:00
631ab8cba5 Remove obsolete OutRes command/query validators
Deleted DeleteOutResCommandValidator and ReadOutResQueryValidator classes, which were marked as obsolete. These validators are no longer needed due to a shift toward using related procedures or views for validation.
2026-01-16 10:37:57 +01:00
872878b9d7 Remove obsolete OutRes and RecAction CQRS classes
Removed deprecated command, query, and mapping classes for OutRes and RecAction entities, including their handlers and AutoMapper profiles. These components were previously marked as obsolete and have been superseded by database procedures or views. This cleanup eliminates redundant code and enforces the use of the updated data access patterns.
2026-01-16 10:36:43 +01:00
5a30b0ece4 Remove ObtainEndpointCommand and its handler
Deleted the ObtainEndpointCommand, its handler, and related using directives. This command was previously used to obtain or create Endpoint entities by URI, but has been removed in favor of using a related procedure or view as indicated by its Obsolete attribute.
2026-01-16 10:36:10 +01:00
37200617ea Remove unused entity-to-DTO mappings from DtoMappingProfile
Cleaned up DtoMappingProfile by removing mappings for several domain entities (OutRes, Connection, Endpoint, EndpointAuth, EndpointParam, Profile, RecAction) to their DTOs. Only view-to-DTO mappings remain. Also removed unused using directives.
2026-01-16 10:35:21 +01:00
cbd52721ac Remove obsolete DbSets from IRecDbContext interface
Removed DbSet properties for entities marked as obsolete in IRecDbContext, including EndpointParam, OutRes, Connection, Endpoint, EndpointAuth, Profile, and RecAction. Retained only DbSets for views and query results to encourage use of views instead of direct entity access. This streamlines the interface and aligns with the intended data access pattern.
2026-01-16 10:24:09 +01:00
4dd54e206e Update EndpointAuth references to fully qualified name
Replaced unqualified EndpointAuth with Domain.Entities.EndpointAuth
in DtoMappingProfile and IRecDbContext to improve clarity and
avoid potential naming conflicts.
2026-01-16 10:18:40 +01:00
459620e1dd Refactor update procedures: rename Guid to Id
Renamed all `Guid` properties and parameters to `Id` in update procedure interfaces, records, and handlers. This clarifies that the identifier is a numeric ID, not a GUID, and improves consistency across the codebase. All related method signatures and usages have been updated accordingly.
2026-01-16 09:53:50 +01:00
5dcd5313a5 Refactor EndpointParams procedures to Commands namespace
Moved Delete, Insert, and UpdateEndpointParamsProcedure classes from Common.Procedures to EndpointParams.Commands for better organization. Updated related imports in InsertObjectProcedure.cs and UpdateObjectProcedure.cs to reflect the new namespace. No functional changes to the procedures themselves.
2026-01-16 09:44:46 +01:00
ef9d725f59 Refactor endpoint procedures to Endpoints.Commands namespace
Moved Delete/Insert/UpdateEndpointProcedure classes from Common.Procedures to Endpoints.Commands namespace. Updated using directives accordingly for improved code organization and maintainability. No changes to class logic.
2026-01-16 09:41:19 +01:00
6f4ab073df Move EndpointAuth procedures to dedicated namespace
Refactored Delete/Insert/UpdateEndpointAuthProcedure records into the new ReC.Application.EndpointAuth.Commands namespace for better organization. Updated using statements in related files to ensure compatibility. No functional changes to the procedure records themselves.
2026-01-16 09:38:59 +01:00
f6b95331e1 Refactor procedure classes into feature-based namespaces
Moved Insert, Update, and Delete procedure records for Action, Profile, and Result entities from common namespaces to feature-specific namespaces. Updated all relevant using directives and controller references. No logic changes; this improves code organization and maintainability.
2026-01-16 09:34:41 +01:00
Developer 02
b9f08bc21c Add DeleteActionProcedure for ACTION entity deletion
Introduced a new `DeleteActionProcedure` record in the
`ReC.Application.Common.Procedures.DeleteProcedure` namespace.

This record implements the `IDeleteProcedure` interface and includes
the following properties:
- `Start`: Starting GUID/ID (inclusive).
- `End`: Ending GUID/ID (inclusive), defaults to `Start` if 0.
- `Force`: Allows deletion even if dependent RESULT data exists.

Added a `ToObjectProcedure` method to convert `DeleteActionProcedure`
to a `DeleteObjectProcedure` with the entity set to `"ACTION"`.
2026-01-16 01:06:56 +01:00
Developer 02
758616c95e Add DeleteEndpointAuthProcedure for endpoint deletion
Introduce the `DeleteEndpointAuthProcedure` record in the new
`ReC.Application.Common.Procedures.DeleteProcedure` namespace.
This record implements the `IDeleteProcedure` interface and
provides properties for specifying a range of GUID/IDs (`Start`
and `End`) and a `Force` flag to allow deletion despite dependent
data.

Add the `ToObjectProcedure` method to convert the record into a
`DeleteObjectProcedure` with the entity set to `"ENDPOINT_AUTH"`.
2026-01-16 01:06:45 +01:00
Developer 02
7376b49e38 Add DeleteEndpointParamsProcedure record
A new `DeleteEndpointParamsProcedure` record was introduced in the
`ReC.Application.Common.Procedures.DeleteProcedure` namespace. This
record implements the `IDeleteProcedure` interface and provides
properties for specifying a range of GUID/IDs (`Start` and `End`)
and a `Force` flag to allow deletion even with dependent data.

The record includes a `ToObjectProcedure` method to convert its
data into a `DeleteObjectProcedure` instance, setting the entity
to `"ENDPOINT_PARAMS"` and mapping the `Start`, `End`, and `Force`
properties.
2026-01-16 01:06:33 +01:00
Developer 02
b65c354ef0 Add DeleteEndpointProcedure for endpoint deletion
Introduced a new `DeleteEndpointProcedure` record in the
`ReC.Application.Common.Procedures.DeleteProcedure` namespace.

This record implements the `IDeleteProcedure` interface and includes
properties for specifying the start and end GUID/ID range, as well as
a `Force` flag to allow deletion even with dependent data.

Added a `ToObjectProcedure` method to convert the record into a
`DeleteObjectProcedure` with the entity set to "ENDPOINT".
2026-01-16 01:06:22 +01:00
Developer 02
38258a98c1 Add DeleteProfileProcedure for profile deletion logic
Introduce the `DeleteProfileProcedure` record in the new
`ReC.Application.Common.Procedures.DeleteProcedure` namespace.
This record implements the `IDeleteProcedure` interface and
provides properties for specifying a range of GUID/IDs
(`Start`, `End`) and a `Force` flag to allow deletion even
with dependent ACTION data.

Added a `ToObjectProcedure` method to convert
`DeleteProfileProcedure` instances into `DeleteObjectProcedure`
objects, setting the `Entity` to `"PROFILE"`.
2026-01-16 01:06:12 +01:00
Developer 02
7666708ab5 Add DeleteResultProcedure for RESULT entity deletion
Introduced a new `DeleteResultProcedure` record in the
`ReC.Application.Common.Procedures.DeleteProcedure` namespace.

This record implements the `IDeleteProcedure` interface and provides
properties for specifying a range of GUID/IDs (`Start` and `End`)
and a `Force` flag.

Added a `ToObjectProcedure` method to convert the record into a
`DeleteObjectProcedure` with the entity set to "RESULT".
2026-01-16 01:06:00 +01:00
Developer 02
d3b67bc429 Add IDeleteProcedure interface for delete operations
Introduced a new namespace `ReC.Application.Common.Procedures.DeleteProcedure` and added the `IDeleteProcedure` interface. This interface defines a `ToObjectProcedure` method, which returns a `DeleteObjectProcedure` object. These changes aim to standardize and encapsulate delete-related procedures in the application.
2026-01-16 01:05:46 +01:00
Developer 02
97f992aef5 Add DeleteObjectProcedure for entity deletion handling
Introduce `DeleteObjectProcedure` to encapsulate parameters for
delete operations, including entity, ID range, and force flag.
Add `DeleteObjectProcedureExtensions` for convenient invocation
via `ISender`. Implement `DeleteObjectProcedureHandler` to
execute the `[dbo].[PRREC_DELETE_OBJECT]` stored procedure
using dynamic SQL parameters.

Throw `DeleteObjectFailedException` on failure and ensure
`End` defaults to `Start` if unset. Add XML documentation
for improved code clarity. Include necessary `using`
directives for dependencies.
2026-01-16 01:05:28 +01:00
Developer 02
cc6f93ae1c Add DeleteObjectFailedException for delete operation errors
A new `DeleteObjectFailedException` class was introduced in the
`ReC.Application.Common.Exceptions` namespace to handle errors
related to failed delete operations.

This class includes:
- A `Procedure` property of type `DeleteObjectProcedure` to
  provide context about the failed operation.
- Three constructors to support different levels of detail
  (procedure only, procedure with a message, and procedure with
  a message and inner exception).

Additionally, a `using` directive for the
`ReC.Application.Common.Procedures.DeleteProcedure` namespace
was added to support the `DeleteObjectProcedure` type.
2026-01-16 01:05:10 +01:00
Developer 02
402990bd3c Add UpdateResultProcedure record for result updates
Introduced a new `UpdateResultProcedure` record in the
`ReC.Application.Common.Procedures.UpdateProcedure` namespace.
This record implements the `IUpdateProcedure` interface and
includes properties for `ActionId`, `StatusId`, `Header`, and
`Body`.

Added a `ToObjectProcedure` method to convert the record into
an `UpdateObjectProcedure` instance, setting the `Entity` to
"RESULT", and allowing optional tracking of changes via the
`ChangedBy` method.
2026-01-16 00:59:43 +01:00
Developer 02
43cdef4910 Add UpdateProfileProcedure record for profile updates
Introduced a new namespace `ReC.Application.Common.Procedures.UpdateProcedure`.
Added the `UpdateProfileProcedure` record implementing the `IUpdateProcedure` interface.
This record includes several nullable properties such as `Active`, `TypeId`, `Name`, `Description`, and others.
Added the `ToObjectProcedure` method to convert the record into an `UpdateObjectProcedure` instance, setting the entity to "PROFILE" and supporting optional change tracking via `ChangedBy`.
2026-01-16 00:59:33 +01:00
Developer 02
348a55fc60 Add UpdateEndpointProcedure record for endpoint updates
A new `UpdateEndpointProcedure` record was introduced in the
`ReC.Application.Common.Procedures.UpdateProcedure` namespace.
This record implements the `IUpdateProcedure` interface and
includes nullable properties `Active`, `Description`, and `Uri`.

The `ToObjectProcedure` method was added to convert the record
into an `UpdateObjectProcedure` instance, setting the `Entity`
to `"ENDPOINT"`, the `Guid` to the provided parameter, and the
`Endpoint` to the current instance. The method also supports
tracking changes via the optional `changedWho` parameter.
2026-01-16 00:59:23 +01:00
Developer 02
719bc9c941 Add UpdateEndpointParamsProcedure record
A new `UpdateEndpointParamsProcedure` record has been added under the `ReC.Application.Common.Procedures.UpdateProcedure` namespace. This record implements the `IUpdateProcedure` interface and includes nullable properties such as `Active`, `Description`, `GroupId`, `Sequence`, `Key`, and `Value`.

Additionally, a `ToObjectProcedure` method has been introduced, which converts the record into an `UpdateObjectProcedure` instance with the `Entity` set to `"ENDPOINT_PARAMS"`, and supports optional tracking of the user who made the change.
2026-01-16 00:59:10 +01:00
Developer 02
37381af042 Add UpdateEndpointAuthProcedure for endpoint updates
Introduce the `UpdateEndpointAuthProcedure` record in the
`ReC.Application.Common.Procedures.UpdateProcedure` namespace.

This class implements the `IUpdateProcedure` interface and includes
properties for managing endpoint authentication details such as
`Active`, `Description`, `TypeId`, `ApiKey`, `ApiValue`, `Token`,
`Username`, `Password`, `Domain`, and `Workstation`.

Add the `ToObjectProcedure` method to convert the procedure into
an `UpdateObjectProcedure` instance, setting the entity to
`ENDPOINT_AUTH` and allowing optional tracking of the user who
made the changes.
2026-01-16 00:58:55 +01:00
Developer 02
34fe996d91 Add UpdateActionProcedure record for update operations
Introduced a new `UpdateActionProcedure` record in the
`ReC.Application.Common.Procedures.UpdateProcedure` namespace.
This record implements the `IUpdateProcedure` interface and
includes several nullable properties such as `ProfileId`,
`Active`, `Sequence`, `EndpointId`, and others to support
update operations.

Added a `ToObjectProcedure` method to the record, which
creates and returns an `UpdateObjectProcedure` instance
with the entity set to "ACTION" and other relevant details.
This method also supports tracking changes via the `ChangedBy`
method.
2026-01-16 00:58:42 +01:00
Developer 02
252fc10243 Add IUpdateProcedure interface for update handling
Introduced a new namespace `ReC.Application.Common.Procedures.UpdateProcedure` and added the `IUpdateProcedure` interface. This interface defines a `ToObjectProcedure` method for converting to an `UpdateObjectProcedure`. The method accepts a `guid` parameter and an optional `changedWho` parameter to track changes. This addition establishes a contract for handling update procedures.
2026-01-16 00:58:26 +01:00
Developer 02
c8a9245b54 Add UpdateObjectProcedure for entity updates
Introduce `UpdateObjectProcedure` to handle updates for various
entities using a stored procedure. Implement MediatR-based
request/response pattern with `IRequest<int>` and add the
`UpdateObjectProcedureHandler` to execute the update logic.

Include an extension method `ExecuteUpdateProcedure` for
simplified execution of update requests. Add exception handling
via `UpdateObjectFailedException` to manage update failures.

Integrate dependencies on `DigitalData.Core.Abstraction.Application.Repository`,
`MediatR`, and `Microsoft.Data.SqlClient`. Ensure extensibility
and reliability in the update process.
2026-01-16 00:58:11 +01:00
Developer 02
c56bcc198e Add UpdateObjectFailedException for update operation errors
A new exception class, `UpdateObjectFailedException`, was added to the `ReC.Application.Common.Exceptions` namespace to handle failures during update operations.

The class includes a `Procedure` property of type `UpdateObjectProcedure` to store the associated procedure. It provides three constructors to support different levels of detail: one with just the procedure, one with a procedure and a custom message, and one with a procedure, a custom message, and an inner exception.

The `UpdateObjectProcedure` type is referenced from the `ReC.Application.Common.Procedures.UpdateProcedure` namespace, which is now included via a `using` directive.
2026-01-16 00:57:37 +01:00
Developer 02
1df9235036 Disambiguate Profile mapping in AutoMapper configuration
Updated the mapping configuration in `DtoMappingProfile` to use
the fully qualified name `Domain.Entities.Profile` for the
`Profile` entity. This change resolves potential ambiguity with
other classes named `Profile` in the codebase.
2026-01-15 23:54:28 +01:00
dd9c1c7ca2 Change default addedWho param to null in ToObjectProcedure
Updated ToObjectProcedure methods in Insert*Procedure records to use null as the default value for the addedWho parameter instead of "Rec.API". This affects InsertActionProcedure, InsertEndpointAuthProcedure, InsertEndpointParamsProcedure, InsertEndpointProcedure, and InsertProfileProcedure.
2026-01-14 17:14:17 +01:00
f9cc735318 Update AddedBy to default to "ReC.API" if no value provided
The AddedBy method in InsertObjectProcedure now accepts an optional parameter and sets AddedWho to "ReC.API" when no argument is supplied, ensuring a consistent default value.
2026-01-14 17:12:15 +01:00
2a8eb3c0ad Mark legacy DbSets as obsolete in IRecDbContext
Several entity-based DbSet properties in IRecDbContext are now marked with [Obsolete("Use Views instead.")], guiding developers to use view-based DbSets. The Profiles DbSet is now explicitly typed as Domain.Entities.Profile. No functional code was removed.
2026-01-14 17:10:55 +01:00
7a4cdb3d1f Support querying multiple profile views in ReadProfileView
Refactored ReadProfileViewQuery and handler to return multiple profiles as IEnumerable<ProfileViewDto>. Made Id parameter optional to allow fetching all profiles. Updated exception handling for empty results.
2026-01-14 16:30:41 +01:00
bd2b5ff62f Add ReadProfileViewQuery and handler for profile views
Introduce CQRS/MediatR query and handler to fetch ProfileView by Id,
optionally including related Actions. Uses repository and AutoMapper,
throws NotFoundException if profile is missing, and returns ProfileViewDto.
2026-01-14 16:12:54 +01:00
df2ebe0cc2 Refactor to use ExecuteInsertProcedure for result insert
Replaced sender.Send and ToObjectProcedure with sender.ExecuteInsertProcedure, passing the InsertResultProcedure object, AddedWho config, and cancellation token directly. This simplifies and clarifies the result insertion process.
2026-01-14 15:00:22 +01:00
5c06f287ab Refactor insert procedure API and add extension method
Changed IInsertProcedure.ToObjectProcedure to accept an optional addedWho parameter. Introduced InsertObjectProcedureExtensions with an ExecuteInsertProcedure extension for ISender, defaulting addedWho to "Rec.API" if not specified.
2026-01-14 14:56:10 +01:00