IUserService
Namespace: SlottyMedia.Backend.Services.Interfaces
This interface defines the methods which can be used to interact with the User table in the database.
public interface IUserService
Methods
GetUserDtoById(Guid)
This method returns a User object from the database based on the given userId.
Task<UserDto> GetUserDtoById(Guid userId)
Parameters
userId Guid
The UserID inside the Database
Returns
Task<UserDto>
UserDao
Exceptions
UserNotFoundException
Thrown when the user is not found.
UserGeneralException
Thrown when a general error occurs.
ExistsByUserName(String)
Checks if a user with the given username exists.
Task<bool> ExistsByUserName(string username)
Parameters
username String
The user's username
Returns
Task<Boolean>
Whether a user with the given username exists
CreateUser(String, String, String, Guid, String, String)
This method creates a new User object in the database and returns the created object.
Task CreateUser(string userId, string username, string email, Guid roleId, string description, string profilePicture)
Parameters
userId String
The UserID from the Authentication Service
username String
The Username, which the User set himself
email String
The Email of the User
roleId Guid
The Role ID of the User
description String
The Description about the User
profilePicture String
The ProfilePicture
Returns
Task
UserDto
Exceptions
UserIudException
Thrown when an error occurs during Insert, Update, or Delete operations.
UserGeneralException
Thrown when a general error occurs.
UpdateUser(UserDao)
This method updates the given User object in the database and returns the updated object.
Task UpdateUser(UserDao user)
Parameters
user UserDao
The User object
Returns
Task
UserDao
Exceptions
UserIudException
Thrown when an error occurs during Insert, Update, or Delete operations.
UserGeneralException
Thrown when a general error occurs.
DeleteUser(UserDto)
This method deletes the given User object from the database.
Task DeleteUser(UserDto user)
Parameters
user UserDto
The User Object
Returns
Task
Return if the User got deleted or not
Exceptions
UserIudException
Thrown when an error occurs during Insert, Update, or Delete operations.
UserGeneralException
Thrown when a general error occurs.
GetProfilePic(Guid)
This method returns the Profile Picture of the given User.
Task<ProfilePicDto> GetProfilePic(Guid userId)
Parameters
userId Guid
The ID of the User
Returns
Task<ProfilePicDto>
Returns the Profile Picture of the User
Exceptions
UserNotFoundException
Thrown when the user is not found.
UserGeneralException
Thrown when a general error occurs.
GetFriends(Guid)
This method returns a list of friends for the given user.
Task<FriendsOfUserDto> GetFriends(Guid userId)
Parameters
userId Guid
The ID of the user
Returns
Task<FriendsOfUserDto>
Returns a FriendsOfUserDto object containing the list of friends
Exceptions
UserNotFoundException
Thrown when the user is not found.
UserGeneralException
Thrown when a general error occurs.
GetCountOfUserFriends(Guid)
This method retrieves the count of friends for a given user from the database.
Task<int> GetCountOfUserFriends(Guid userId)
Parameters
userId Guid
The ID of the user whose friends count is to be retrieved.
Returns
Task<Int32>
Returns the count of friends for the specified user.
Exceptions
UserGeneralException
Thrown when a general database error occurs while fetching the friends count.
GetCountOfUserSpaces(Guid)
Gets all spaces a user has wrote in
Task<int> GetCountOfUserSpaces(Guid userId)
Parameters
userId Guid
User from which it should be retrieved
Returns
Task<Int32>
Returns the amount of spaces as task
Exceptions
UserGeneralException
Thrown when a general error occurs.
UpdateUser(UserDto)
Updates the given UserDto object in the database and returns the updated object.
Task UpdateUser(UserDto user)
Parameters
user UserDto
The UserDto object to be updated.
Returns
Task
A task that represents the asynchronous operation. The task result contains the updated UserDto object.
Exceptions
UserIudException
Thrown when an error occurs during Insert, Update, or Delete operations.
UserGeneralException
Thrown when a general error occurs.
UserFollowRelation(Guid, Guid)
Checks whether a user follows another user based on their ids
Task<bool> UserFollowRelation(Guid userIdToCheck, Guid userIdLoggedIn)
Parameters
userIdToCheck Guid
UserId to check
userIdLoggedIn Guid
UserId that may follow the one to check
Returns
Task<Boolean>
Boolean representing the state
Exceptions
UserGeneralException
Thrown when a general error occurs.
GetUserDaoById(Guid)
Gets a user dao based on the user id
Task<UserDao> GetUserDaoById(Guid userId)
Parameters
userId Guid
Id to retrieve
Returns
Task<UserDao>
Returns a user dao
Exceptions
UserNotFoundException
Thrown when the user is not found.
UserGeneralException
Thrown when a general error occurs.
FollowUserById(Guid, Guid)
Method used to follow a user by id
Task FollowUserById(Guid userIdFollows, Guid userIdToFollow)
Parameters
userIdFollows Guid
The user that tries to follow another
userIdToFollow Guid
The user that the user tries to follow
Returns
Task
Task
Exceptions
UserIudException
Thrown when an error occurs during Insert, Update, or Delete operations.
UserGeneralException
Thrown when a general error occurs.
UnfollowUserById(Guid, Guid)
Method used to unfollow a user by id
Task UnfollowUserById(Guid userIdFollows, Guid userIdToUnfollow)
Parameters
userIdFollows Guid
The user that tries to unfollow another
userIdToUnfollow Guid
The user that the user tries to unfollow
Returns
Task
Task
Exceptions
UserIudException
Thrown when an error occurs during Insert, Update, or Delete operations.
UserGeneralException
Thrown when a general error occurs.
GetUserInfo(Guid, Boolean, Boolean)
This sets a dto holding information about the current user in order to show the current users infos in the profile card
Task<UserInformationDto> GetUserInfo(Guid userId, bool fetchFriends, bool fetchSpaces)
Parameters
userId Guid
User from which the dto should be retrieved
fetchFriends Boolean
Determines if the Method should fetch the Friends Count of a User
fetchSpaces Boolean
Determines if the Method should fetch the Spaces Count of a User
Returns
Task<UserInformationDto>
Returns a task of type UserInformationDto. The dto is used to update the state in the view.