Table of Contents

Class UpdateProfileCommand

Namespace
Core.CliniCore.Commands.Profile
Assembly
Core.CliniCore.dll

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

profileService ProfileService

The ProfileService instance used to perform profile updates. Cannot be null.

Exceptions

ArgumentNullException

Thrown if profileService is null.

Fields

Key

The unique key used to identify this command.

public const string Key = "updateprofile"

Field Value

string

Properties

CanUndo

Whether this command can be undone - defaults to false

public override bool CanUndo { get; }

Property Value

bool

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

string

Description

Description of what this command does

public override string Description { get; }

Property Value

string

Methods

ExecuteCore(CommandParameters, SessionContext?)

Executes the core command logic - must be implemented by derived classes

protected override CommandResult ExecuteCore(CommandParameters parameters, SessionContext? session)

Parameters

parameters CommandParameters
session SessionContext

Returns

CommandResult

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

role UserRole

Returns

List<string>

GetRequiredPermission()

Gets the required permission to execute this command

public override Permission? GetRequiredPermission()

Returns

Permission?

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

parameters CommandParameters

The CommandParameters instance containing the parameters to validate. Must include a non-empty ProfileId parameter.

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

parameters CommandParameters
session SessionContext

Returns

CommandValidationResult