Skip to content

IPostService

Namespace: SlottyMedia.Backend.Services.Interfaces

Interface for post-related services.

public interface IPostService

Methods

GetAllPosts(PageRequest)

Fetches all posts sorted by date in descending order. Fetches only a specified number of posts on the specified page.

Task<IPage<PostDto>> GetAllPosts(PageRequest pageRequest)

Parameters

pageRequest PageRequest
The page request

Returns

Task<IPage<PostDto>>
A task that represents the asynchronous operation. The task result contains a list of PostDto objects.

Exceptions

PostNotFoundException
Thrown when the posts are not found.

PostGeneralException
Thrown when a general error occurs.

CountAllPosts()

Counts all existing posts.

Task<int> CountAllPosts()

Returns

Task<Int32>
The total number of existing posts

GetPostById(Guid)

Attempts to fetch a post by ID. Returns null if such a post could not be found.

Task<PostDto> GetPostById(Guid postId)

Parameters

postId Guid
The post's ID.

Returns

Task<PostDto>
A task that represents the asynchronous operation. The task result contains the post or null if not found.

Exceptions

PostNotFoundException
Thrown when the post is not found.

PostGeneralException
Thrown when a general error occurs.

InsertPost(String, Guid, Guid)

Inserts a new post into the database.

Task InsertPost(string content, Guid creatorUserId, Guid forumId)

Parameters

content String
The content of the post.

creatorUserId Guid
The UserId who created the post.

forumId Guid
The ID of the forum the post should belong to.

Returns

Task
A task that represents the asynchronous operation. The task result contains the inserted post.

Exceptions

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

PostGeneralException
Thrown when a general error occurs.

UpdatePost(PostsDao)

Updates an existing post in the database.

Task UpdatePost(PostsDao post)

Parameters

post PostsDao
The post to update.

Returns

Task
A task that represents the asynchronous operation. The task result contains the updated post.

Exceptions

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

PostGeneralException
Thrown when a general error occurs.

DeletePost(PostsDao)

Deletes a post from the database.

Task DeletePost(PostsDao post)

Parameters

post PostsDao
The post to delete.

Returns

Task
A task that represents the asynchronous operation. The task result indicates whether the deletion was successful.

Exceptions

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

PostGeneralException
Thrown when a general error occurs.

GetForumCountByUserId(Guid)

This method fetches the number of forums the user has created posts in.

Task<int> GetForumCountByUserId(Guid userId)

Parameters

userId Guid
The ID of the user.

Returns

Task<Int32>
A task that represents the asynchronous operation. The task result contains the number of forums.

Exceptions

PostGeneralException
Thrown when a general error occurs.

GetPostsByUserId(Guid, PageRequest)

Gets posts of a user by their id and enables slicing via offsets.

Task<IPage<PostDto>> GetPostsByUserId(Guid userId, PageRequest pageRequest)

Parameters

userId Guid
The ID of the user that the posts belong to.

pageRequest PageRequest
The page request

Returns

Task<IPage<PostDto>>
A task that represents the asynchronous operation. The task result contains a list of PostDto objects.

Exceptions

PostNotFoundException
Thrown when the posts are not found.

PostGeneralException
Thrown when a general error occurs.

GetPostsByForumId(Guid, PageRequest)

Gets posts by forum ID and enables slicing via offsets.

Task<IPage<PostDto>> GetPostsByForumId(Guid forumId, PageRequest pageRequest)

Parameters

forumId Guid
The ID of the forum that the posts belong to.

pageRequest PageRequest
The page request

Returns

Task<IPage<PostDto>>
A task that represents the asynchronous operation. The task result contains a list of PostDto objects.

Exceptions

PostNotFoundException
Thrown when the posts are not found.

PostGeneralException
Thrown when a general error occurs.