Commit Graph

231 Commits

Author SHA1 Message Date
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
c3e3a0377d Switch to InsertResultProcedure for result handling
Replaced CreateOutResCommand with InsertResultProcedure when sending results. Updated property names (StatusId instead of Status) and now use ToObjectProcedure to include AddedWho. Added InsertProcedure namespace import.
2026-01-14 14:40:30 +01:00
cf34a54170 Mark CreateResultViewCommand as obsolete, add handler
CreateResultViewCommand is now marked obsolete, advising use of related procedures or views instead. Added an obsolete CreateResultViewCommandHandler that delegates creation to the repository.
2026-01-14 14:36:30 +01:00
16f48f125b Refactor ToObjectProcedure default parameter handling
Changed ToObjectProcedure to use a nullable addedWho parameter and set "Rec.API" as a fallback within the method, ensuring consistent default behavior.
2026-01-14 14:32:17 +01:00
563375f6e3 Refactor validator to use nested property accessors
Update InsertObjectProcedureValidator to reference nested properties (e.g., x.Action.ProfileId instead of x.ActionProfileId) throughout all entity validation rules. Adjust .When conditions accordingly to match the new data model structure with grouped sub-objects.
2026-01-14 13:17:10 +01:00
35e03269e7 Add DbSets for EndpointParam and view entities
Added DbSet properties for EndpointParam, RecActionView, and ProfileView to both IRecDbContext and RecDbContext. This enables querying and interaction with these entities and views in the database. Grouped the new DbSets under a #region for better code organization.
2026-01-14 12:00:36 +01:00
8b212d541e Refactor AddedWho assignment in InsertObjectProcedure
AddedWho is now set via the AddedBy method instead of direct assignment in object initializers. The property is made internal with a private setter to prevent external modification. All ToObjectProcedure methods in insert procedure records are updated to use AddedBy for consistency and encapsulation.
2026-01-14 11:51:42 +01:00
dd4cecc15d Rename InsertObjectFailedException.Request to Procedure
Updated ExceptionHandlingMiddleware to use the new Procedure property name when logging InsertObjectFailedException. Changed error title for BadRequestException to "Bad Procedure". Removed unused System.Text.Json using directive from InsertObjectProcedure.cs.
2026-01-14 09:54:19 +01:00
0dedb506e1 Handle InsertObjectFailedException in middleware
Add specific handling for InsertObjectFailedException in ExceptionHandlingMiddleware, including detailed logging and custom error response. Refactor InsertObjectFailedException to expose the request data via a public property for improved error reporting.
2026-01-14 09:51:40 +01:00
24f146ca26 Refactor InsertObjectFailedException for more context
InsertObjectFailedException now requires an InsertObjectProcedure
instance, improving error context. Exception throwing in
InsertObjectProcedureHandler updated to pass the procedure object
instead of just a message and serialized request.
2026-01-14 09:44:31 +01:00
2692553865 Add 'addedWho' param to insert procedures for auditing
Updated IInsertProcedure and all implementations to accept an optional 'addedWho' parameter in ToObjectProcedure, defaulting to "Rec.API". This enables tracking of the entity responsible for insert operations.
2026-01-14 09:37:17 +01:00
d90c2fab96 Refactor: split insert procedures into separate files
Refactored insert procedure-related classes by moving each record type (Action, Endpoint, EndpointAuth, Profile, Result, EndpointParams) and the IInsertProcedure interface into their own files under the new InsertProcedure namespace. Updated InsertObjectProcedureValidator to use the new namespace. This improves code organization, readability, and maintainability.
2026-01-14 09:26:27 +01:00
854e36e71f Refactor insert procedures with entity-specific records
Refactored insert procedure modeling by introducing the IInsertProcedure interface and entity-specific Insert[Entity]Procedure records. Each entity now has its own record with relevant properties and a ToObjectProcedure() method, improving type safety, clarity, and extensibility for insert operations. Updated InsertObjectProcedure to use these new types.
2026-01-14 09:18:52 +01:00
1d31f2aff9 Refactor InsertObjectProcedure to use nested records
Reorganized InsertObjectProcedure by grouping related properties into nested record types (Action, Endpoint, EndpointAuth, Profile, Result, EndpointParams) for better encapsulation and maintainability. Updated handler logic to use new structure and set AddedWhen to DateTime.UtcNow. Improved error logging and added System.Text.Json usage.
2026-01-12 16:47:57 +01:00
11206cf84f Throw exception on failed InsertObject identifier return
Replace default return of 0 with InsertObjectFailedException when the stored procedure does not return a valid identifier. Exception message includes serialized request for easier debugging. Added necessary imports for exception and JSON serialization.
2026-01-12 16:27:45 +01:00
b48ebd8e88 Refactor InsertObjectFailedException constructors
Refactored InsertObjectFailedException to use explicit constructors: parameterless, message-only, and message with inner exception. Removed constructors with optional parameters for clearer and more standard .NET exception handling.
2026-01-12 16:21:16 +01:00
12d17e0808 Add InsertObjectFailedException custom exception class
Introduced InsertObjectFailedException in the ReC.Application.Common.Exceptions namespace. This exception provides constructors for custom messages and inner exceptions, and is intended to signal failures during object insertion operations.
2026-01-12 16:16:52 +01:00
1dee3180d5 Refactor InsertObjectProcedure into entity-based regions
Organized properties into regions by target entity for clarity.
No functional changes; update improves code readability
and maintainability.
2026-01-12 16:07:52 +01:00
bd4046a6c1 Add InsertObjectProcedureValidator with entity-specific rules
Introduced InsertObjectProcedureValidator using FluentValidation to enforce required fields and string length constraints for InsertObjectProcedure. Validation rules are applied conditionally based on the Entity type, ensuring correct data for ACTION, ENDPOINT, PROFILE, RESULT, and ENDPOINT_PARAMS. Optional string fields also receive length checks.
2026-01-12 16:03:10 +01:00
af6f94c1ed Improve handling of stored procedure return value type
Check if return value is already a long before parsing its
string representation. This enhances robustness and efficiency
when the value is of the correct type.
2026-01-12 15:48:03 +01:00
7bfb56b664 Add InsertObjectProcedure MediatR command and handler
Introduces InsertObjectProcedure and its handler to support generic, parameterized insertion of various object types (ACTION, ENDPOINT, etc.) via a single stored procedure. The handler maps request properties to SQL parameters, executes the procedure, and returns the output GUID. This enables flexible and unified object creation through MediatR.
2026-01-12 15:19:54 +01:00
1a6eced316 Rename InsertObject to InsertObjectProcedure
Renamed the InsertObject MediatR request record to InsertObjectProcedure and moved it from InsertObject.cs to InsertObjectProcedure.cs. The structure and functionality remain unchanged; it still defines an Entity property with a default value of "ACTION".
2026-01-12 14:35:16 +01:00
aaa7beb92a Add RecResults DbSet for InsertObjectResult entities
Added RecResults DbSet to IRecDbContext and RecDbContext to support managing InsertObjectResult entities. Updated IRecDbContext to include the new DbSet and ensured SaveChangesAsync is defined. Enables querying and persisting InsertObjectResult via EF Core.
2026-01-12 14:19:19 +01:00
5cce52ec27 Add ProfileViews and RecResultViews to IRecDbContext
Updated IRecDbContext to include DbSet properties for ProfileView and ResultView entities, enabling management of these collections within the context.
2026-01-12 14:17:34 +01:00
92e8d9e778 Move query result classes to QueryOutput namespace
BodyQueryResult and HeaderQueryResult were relocated from ReC.Domain.Entities to ReC.Domain.QueryOutput. Updated all references in IRecDbContext and RecDbContext to use the new namespace.
2026-01-12 14:11:05 +01:00
2d04670fef Set default Entity to "ACTION" in InsertObject
Added XML summary to Entity property describing valid values.
Changed default value from null to "ACTION" for clarity.
2026-01-12 14:08:03 +01:00
c0085b4c18 Add InsertObject record for MediatR-based insert requests
Introduced InsertObject record in ReC.Application.Common.Procedures namespace. This record implements MediatR's IRequest<long> and includes a non-nullable Entity property to support object insertion operations.
2026-01-12 13:54:04 +01:00
59ea5e3e67 Update action invocation logic and remove EndpointAuth include
Changed invocation filter to use Results.Any() instead of Root.OutRes.
Removed eager loading of EndpointAuth from the query.
2026-01-12 13:26:54 +01:00
fb12cb6c98 Refactor ResultView logic under OutResults namespace
Moved ReadResultViewQuery and its handler from ResultViews to OutResults namespace. Merged ResultView mapping profile into OutResults.MappingProfiles and removed the old MappingProfile class. Updated controller references accordingly for improved organization.
2026-01-12 11:32:39 +01:00
2635bfb223 Move CreateResultViewCommand to OutResults.Commands
Relocated CreateResultViewCommand and its handler from ResultViews.Commands to OutResults.Commands. Updated all namespace references and using directives accordingly. Modified the project file to include the new folder structure. No functional changes to the command or handler logic.
2026-01-12 11:30:46 +01:00
5245cd04ff Refactor: move RecActionViewQuery and MappingProfile
Moved ReadRecActionViewQuery and MappingProfile from RecActionViews to RecActions namespace. Updated all references and using directives accordingly. This organizational change consolidates related queries and mapping profiles for improved clarity and maintainability.
2026-01-12 11:27:51 +01:00
9d5334e7dc Move RecActionView commands to RecActions namespace
Refactored InvokeBatchRecActionViewsCommand and InvokeRecActionViewCommand to ReC.Application.RecActions.Commands. Updated related handlers, records, and extension methods to use the new namespace. Removed obsolete using statement in RecActionController. No functional changes; organizational update only.
2026-01-12 11:21:26 +01:00
e5bb61376a Mark ObtainEndpointCommand and mapping as obsolete
Mark ObtainEndpointCommand, its handler, and related mapping
profile as [Obsolete] with guidance to use the new procedure
or view-based approach. This deprecates the old command and
mapping logic in favor of updated patterns.
2026-01-12 11:07:17 +01:00
d3aa8c715b Mark fake OutRes endpoints and queries as [Obsolete]
Added [Obsolete] attribute to "fake" Get methods in OutResController, as well as to ReadOutResQuery, ReadOutResHandler, and ReadOutResQueryValidator. These components are now deprecated in favor of related procedures or views. No functional changes were made.
2026-01-12 11:02:27 +01:00
6720e66b23 Mark DeleteOutResCommand and related classes as obsolete
Added the [Obsolete("Use the related procedure or view.")] attribute to DeleteOutResCommand, its handler, and its validator to indicate these should no longer be used and to guide consumers toward the recommended procedure or view.
2026-01-12 11:00:21 +01:00
71470fc21d Mark CreateOutResCommandHandler and MappingProfiles obsolete
Both CreateOutResCommandHandler and the MappingProfiles constructor are now marked with [Obsolete] attributes, warning developers to use the related procedure or view instead. This signals that these components are deprecated and may be removed in the future.
2026-01-12 10:59:24 +01:00
9191ec4179 Update [Obsolete] messages to mention procedures or views
Updated [Obsolete] attribute messages across several commands,
handlers, and the mapping profile to clarify that related
procedures or views should be used instead. Added [Obsolete]
to CreateOutResCommand. No functional changes made.
2026-01-12 10:52:41 +01:00
e0d83c0a14 Mark RecAction commands and endpoints as obsolete
Added [Obsolete("Use the related procedure.")] to RecAction creation and deletion commands, handlers, mapping profile, and related controller endpoints to indicate deprecation. No functional changes were made.
2026-01-12 10:50:39 +01:00
284ced6059 refactor(ResultView): move to Views directory 2026-01-12 10:34:27 +01:00