Class UpdateProfileCommand
Router command that delegates to the appropriate profile-specific update command based on the profile type being updated. This allows for a single entry point while maintaining type-specific validation and field handling.
public class UpdateProfileCommand : AbstractCommand, ICommand
- Inheritance
-
UpdateProfileCommand
- Implements
- Inherited Members
Constructors
UpdateProfileCommand(ProfileService)
Initializes a new instance of the UpdateProfileCommand class using the specified profile service.
public UpdateProfileCommand(ProfileService profileService)
Parameters
profileServiceProfileServiceThe ProfileService instance used to perform profile updates. Cannot be null.
Exceptions
- ArgumentNullException
Thrown if
profileServiceis null.
Fields
Key
The unique key used to identify this command.
public const string Key = "updateprofile"
Field Value
Properties
CanUndo
Whether this command can be undone - defaults to false
public override bool CanUndo { get; }
Property Value
CommandKey
Unique key identifier for this command type Generated from the class name, converted to lowercase without "Command" suffix E.g., "LoginCommand" becomes "login", "CreatePatientCommand" becomes "createpatient"
public override string CommandKey { get; }
Property Value
Description
Description of what this command does
public override string Description { get; }
Property Value
Methods
ExecuteCore(CommandParameters, SessionContext?)
Executes the core command logic - must be implemented by derived classes
protected override CommandResult ExecuteCore(CommandParameters parameters, SessionContext? session)
Parameters
parametersCommandParameterssessionSessionContext
Returns
GetEditableFieldsForProfileType(UserRole)
Helper method to get editable fields for a specific profile type. Used by the console layer to determine which fields to prompt for.
public static List<string> GetEditableFieldsForProfileType(UserRole role)
Parameters
roleUserRole
Returns
GetRequiredPermission()
Gets the required permission to execute this command
public override Permission? GetRequiredPermission()
Returns
ValidateParameters(CommandParameters)
Validates the specified command parameters to ensure that a valid profile identifier is provided and that the corresponding profile exists.
protected override CommandValidationResult ValidateParameters(CommandParameters parameters)
Parameters
parametersCommandParametersThe CommandParameters instance containing the parameters to validate. Must include a non-empty
ProfileIdparameter.
Returns
- CommandValidationResult
A CommandValidationResult indicating the outcome of the validation. The result contains errors if required parameters are missing, the profile identifier is invalid, or the profile does not exist.
Remarks
This method checks for the presence and validity of the ProfileId parameter
and verifies that a profile with the specified identifier exists in the registry. Additional parameter
validation may be performed by derived command implementations.
ValidateSpecific(CommandParameters, SessionContext?)
Performs command-specific validation - override in derived classes if needed
protected override CommandValidationResult ValidateSpecific(CommandParameters parameters, SessionContext? session)
Parameters
parametersCommandParameterssessionSessionContext