Table of Contents

Interface IBlogRepository

Namespace
Builvero.Application.Interfaces.Repositories
Assembly
Builvero.Application.dll

Defines the contract for blog post data access operations including retrieval, creation, updates, and deletion.

public interface IBlogRepository

Methods

CreateAsync(BlogPost, CancellationToken)

Creates a new blog post entity in the database.

Task<BlogPost> CreateAsync(BlogPost blogPost, CancellationToken cancellationToken = default)

Parameters

blogPost BlogPost

The blog post entity to create.

cancellationToken CancellationToken

Cancellation token to cancel the operation.

Returns

Task<BlogPost>

The created blog post entity with generated ID and timestamps.

DeleteAsync(BlogPost, CancellationToken)

Deletes a blog post entity from the database.

Task DeleteAsync(BlogPost blogPost, CancellationToken cancellationToken = default)

Parameters

blogPost BlogPost

The blog post entity to delete.

cancellationToken CancellationToken

Cancellation token to cancel the operation.

Returns

Task
Defines the contract for blog post data access operations including retrieval, creation, updates, and deletion.

GetAllAsync(bool, CancellationToken)

Retrieves all blog posts, optionally filtered by publication status.

Task<List<BlogPost>> GetAllAsync(bool publishedOnly = false, CancellationToken cancellationToken = default)

Parameters

publishedOnly bool

If true, returns only published posts; otherwise returns all posts.

cancellationToken CancellationToken

Cancellation token to cancel the operation.

Returns

Task<List<BlogPost>>

A list of blog posts ordered by creation date (newest first).

GetByIdAsync(Guid, CancellationToken)

Retrieves a blog post by its unique identifier.

Task<BlogPost?> GetByIdAsync(Guid id, CancellationToken cancellationToken = default)

Parameters

id Guid

The unique identifier of the blog post to retrieve.

cancellationToken CancellationToken

Cancellation token to cancel the operation.

Returns

Task<BlogPost>

The blog post entity if found; otherwise, null.

GetBySlugAsync(string, CancellationToken)

Retrieves a blog post by its slug.

Task<BlogPost?> GetBySlugAsync(string slug, CancellationToken cancellationToken = default)

Parameters

slug string

The slug of the blog post to retrieve.

cancellationToken CancellationToken

Cancellation token to cancel the operation.

Returns

Task<BlogPost>

The blog post entity if found; otherwise, null.

SlugExistsAsync(string, Guid?, CancellationToken)

Checks if a slug already exists in the database.

Task<bool> SlugExistsAsync(string slug, Guid? excludeId = null, CancellationToken cancellationToken = default)

Parameters

slug string

The slug to check.

excludeId Guid?

Optional blog post ID to exclude from the check (for updates).

cancellationToken CancellationToken

Cancellation token to cancel the operation.

Returns

Task<bool>

True if the slug exists; otherwise, false.

UpdateAsync(BlogPost, CancellationToken)

Updates an existing blog post entity in the database.

Task<BlogPost> UpdateAsync(BlogPost blogPost, CancellationToken cancellationToken = default)

Parameters

blogPost BlogPost

The blog post entity with updated values.

cancellationToken CancellationToken

Cancellation token to cancel the operation.

Returns

Task<BlogPost>

The updated blog post entity.