using Domain.Entities;
namespace Service.Breweries;
///
/// Represents the data required to create a new brewery post.
///
/// The unique identifier of the user creating the post.
/// The name of the brewery.
/// A description of the brewery.
/// The location details for the new brewery post.
public record BreweryCreateRequest(
Guid PostedById,
string BreweryName,
string Description,
BreweryLocationCreateRequest Location
);
///
/// Represents the location data required to create a new brewery post.
///
/// The unique identifier of the city the brewery is located in.
/// The primary address line.
/// An optional secondary address line.
/// The postal code of the brewery's address.
/// Optional geographic coordinates for the brewery's location.
public record BreweryLocationCreateRequest(
Guid CityId,
string AddressLine1,
string? AddressLine2,
string PostalCode,
byte[]? Coordinates
);
///
/// Represents the data required to update an existing brewery post.
///
/// The unique identifier of the brewery post to update.
/// The unique identifier of the user who owns/posted the brewery.
/// The updated name of the brewery.
/// The updated description of the brewery.
/// The updated location details, or null to clear the location.
public record BreweryUpdateRequest(
Guid BreweryPostId,
Guid PostedById,
string BreweryName,
string Description,
BreweryLocationUpdateRequest? Location
);
///
/// Represents the location data required to update an existing brewery post.
///
/// The unique identifier of the existing brewery location record.
/// The unique identifier of the city the brewery is located in.
/// The primary address line.
/// An optional secondary address line.
/// The postal code of the brewery's address.
/// Optional geographic coordinates for the brewery's location.
public record BreweryLocationUpdateRequest(
Guid BreweryPostLocationId,
Guid CityId,
string AddressLine1,
string? AddressLine2,
string PostalCode,
byte[]? Coordinates
);
///
/// Represents the result of a create or update operation against a brewery post.
///
public record BreweryServiceReturn
{
///
/// Gets a value indicating whether the operation succeeded.
///
public bool Success { get; init; }
///
/// Gets the resulting brewery post when the operation succeeded; otherwise a default/unset value.
///
public BreweryPost Brewery { get; init; }
///
/// Gets a message describing the failure reason, empty when is true.
///
public string Message { get; init; } = string.Empty;
///
/// Initializes a new successful result wrapping the given brewery post.
///
/// The brewery post resulting from the operation.
public BreweryServiceReturn(BreweryPost brewery)
{
Success = true;
Brewery = brewery;
}
///
/// Initializes a new failed result with the given error message.
///
/// A message describing why the operation failed.
public BreweryServiceReturn(string message)
{
Success = false;
Brewery = default!;
Message = message;
}
}
///
/// Defines operations for retrieving, creating, updating, and deleting brewery posts.
///
public interface IBreweryService
{
///
/// Retrieves a brewery post by its unique identifier.
///
/// The unique identifier of the brewery post.
/// The matching , or null if no such post exists.
Task GetByIdAsync(Guid id);
///
/// Retrieves all brewery posts, optionally paginated.
///
/// The maximum number of results to return, or null for no limit.
/// The number of results to skip, or null to start from the beginning.
/// A collection of entities.
Task> GetAllAsync(int? limit = null, int? offset = null);
///
/// Creates a new brewery post.
///
/// The details of the brewery post to create.
/// A describing the outcome of the creation.
Task CreateAsync(BreweryCreateRequest request);
///
/// Updates an existing brewery post.
///
/// The updated details of the brewery post.
/// A describing the outcome of the update.
Task UpdateAsync(BreweryUpdateRequest request);
///
/// Deletes a brewery post by its unique identifier.
///
/// The unique identifier of the brewery post to delete.
/// A task that completes once the deletion has finished.
Task DeleteAsync(Guid id);
}