Skip to content

ICommentService

Namespace: SlottyMedia.Backend.Services.Interfaces

The ICommentService interface is responsible for handling comment related operations.

public interface ICommentService

Methods

GetCommentById(Guid)

Fetches a comment by its ID.

Task<CommentDto> GetCommentById(Guid commentId)

Parameters

commentId Guid
The comment's ID

Returns

Task<CommentDto>
The comment

InsertComment(Guid, Guid, String)

Inserts a new comment into the database.

Task InsertComment(Guid creatorUserId, Guid postId, string content)

Parameters

creatorUserId Guid
The ID of the user who created the comment.

postId Guid
The ID of the post to which the comment belongs.

content String
The content of the comment.

Returns

Task
Returns the inserted CommentDto object.

Exceptions

CommentIudException
Thrown when an error occurs during Insert, Update, or Delete operations.

CommentGeneralException
Thrown when a general error occurs.

UpdateComment(CommentDao)

Updates an existing comment in the database.

Task UpdateComment(CommentDao comment)

Parameters

comment CommentDao
The CommentDto object containing the updated comment details.

Returns

Task
Returns the updated CommentDto object.

Exceptions

CommentIudException
Thrown when an error occurs during Insert, Update, or Delete operations.

CommentGeneralException
Thrown when a general error occurs.

DeleteComment(CommentDao)

Deletes a comment from the database.

Task DeleteComment(CommentDao comment)

Parameters

comment CommentDao
The CommentDto object containing the comment details.

Returns

Task
Returns a Task representing the asynchronous operation.

Exceptions

CommentIudException
Thrown when an error occurs during Insert, Update, or Delete operations.

CommentGeneralException
Thrown when a general error occurs.

CountCommentsInPost(Guid)

Counts the total number of comments in the given post.

Task<int> CountCommentsInPost(Guid postId)

Parameters

postId Guid
The post to query

Returns

Task<Int32>
The total number of comments

GetCommentsInPost(Guid, PageRequest)

Fetches all comments in the given post. Utilizes pagination in order to limit the total number of queried posts: Only posts on the given page will be fetched.

Task<IPage<CommentDto>> GetCommentsInPost(Guid postId, PageRequest pageRequest)

Parameters

postId Guid
The post whose comments should be fetched

pageRequest PageRequest
The page request

Returns

Task<IPage<CommentDto>>
A list containing the queried posts