Interface IGuildService
- Namespace
- FishMMO.Database.Npgsql.Services.Interfaces
- Assembly
- FishMMO-DB.dll
Service interface for guild management operations. Provides async methods for guild creation, deletion, and retrieval.
public interface IGuildService : IExistsByKeyAction<string>, IPersistAction<string, long?>, IDeleteByKeyAction<long>, IFetchByKeyAction<long, GuildData?>, IFetchByKeyAction<string, GuildData?>
- Inherited Members
Remarks
Write operations (Persist*, Delete*) in this service use execution strategies to ensure transient database failures are automatically retried according to the retry policy configured on the DbContext. Execution is wrapped by BaseService for retries and exception mapping.
All methods return DatabaseResult or DatabaseResult<T> to provide structured error information through the DatabaseException system, helping distinguish between: - Validation failures (invalid parameters) - Business rule violations (name already exists) - Database errors (connection issues, constraint violations, timeouts) - Entity not found errors - Unexpected runtime errors
Name lookups are case-insensitive by using a normalized field (e.g. name_lowercase) in the database.
Methods
FetchNameAsync(long, CancellationToken)
Fetches the name of a guild by ID.
Task<DatabaseResult<string?>> FetchNameAsync(long guildId, CancellationToken cancellationToken = default)
Parameters
guildIdlongGuild ID.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<DatabaseResult<string>>
A DatabaseResult<T> containing the guild name on success, or
nullif the guild was not found. Returns a failure result on database errors.
Remarks
This method uses LINQ (FirstOrDefaultAsync with AsNoTracking) and automatically benefits from the retry policy configured on the DbContext without requiring explicit execution strategy wrapping.
PersistMessageOfTheDayAsync(long, string, CancellationToken)
Updates the message of the day for a guild.
Task<DatabaseResult> PersistMessageOfTheDayAsync(long guildId, string messageOfTheDay, CancellationToken cancellationToken = default)
Parameters
guildIdlongGuild ID.
messageOfTheDaystringThe new message of the day text.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<DatabaseResult>
DatabaseResult indicating success or failure.
PersistNoticeAsync(long, string, CancellationToken)
Updates the notice text for a guild.
Task<DatabaseResult> PersistNoticeAsync(long guildId, string notice, CancellationToken cancellationToken = default)
Parameters
guildIdlongGuild ID.
noticestringThe new notice text.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<DatabaseResult>
DatabaseResult indicating success or failure.
Remarks
The sibling of PersistMessageOfTheDayAsync(long, string, CancellationToken). The notice column has
existed since the guild table was created with no way to write it; the two are kept
separate because a notice is standing text about the guild while the message of the day
is transient, and a single setter would force callers to read-modify-write the other.
PersistRecruitmentAsync(long, string, string, bool, CancellationToken)
Updates the guild's recruitment advertisement.
Task<DatabaseResult> PersistRecruitmentAsync(long guildId, string blurb, string tags, bool isRecruiting, CancellationToken cancellationToken = default)
Parameters
guildIdlongGuild ID.
blurbstringAdvertisement text shown to non-members.
tagsstringComma-separated tags; stored lower-cased for search.
isRecruitingboolWhether the guild is listed in the directory.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<DatabaseResult>
DatabaseResult indicating success or failure.
Remarks
One setter for all three fields rather than three. They are edited together from one form, and separate setters would make "stop recruiting" a two-write operation with a window in which the guild is listed with a blurb it has just withdrawn.