Skip to content

IUserService

Namespace: Rest_API.Services.User

Service interface for user management operations including user retrieval, updates, and deletion.

public interface IUserService

Methods

ChangePassword(ApiUser, String, String)

Changes a user's password after validating the current password.

Task ChangePassword(ApiUser user, string currentPassword, string newPassword)

Parameters

user ApiUser

The user whose password will be changed.

currentPassword String

The user's current password for validation.

newPassword String

The new password to set.

Returns

A task representing the asynchronous password change operation.

Exceptions

ArgumentException

Thrown when parameters are null or invalid.

UnauthorizedAccessException

Thrown when current password is incorrect.

ChangeUser(ApiUser)

Updates user information in the system.

Task ChangeUser(ApiUser user)

Parameters

user ApiUser

The user object with updated information.

Returns

A task representing the asynchronous user update operation.

Exceptions

ArgumentException

Thrown when user is null or contains invalid data.

InvalidOperationException

Thrown when user update fails.

DeleteUser(ApiUser)

Deletes a user from the system.

Task<Boolean> DeleteUser(ApiUser user)

Parameters

user ApiUser

The user to delete from the system.

Returns

A task containing true if deletion was successful, false otherwise.

Exceptions

ArgumentException

Thrown when user is null.

InvalidOperationException

Thrown when user deletion fails.

GetUserById(String)

Retrieves a specific user by their unique identifier.

Task<ApiUser> GetUserById(string userId)

Parameters

userId String

The unique identifier of the user to retrieve.

Returns

A task containing the user if found, or null if not found.

Exceptions

ArgumentException

Thrown when userId is null or empty.

GetUserInformations()

Retrieves a list of all users in the system.

Task<List<ApiUser>> GetUserInformations()

Returns

A task containing a list of all API users.

Exceptions

UnauthorizedAccessException

Thrown when user lacks sufficient permissions.