add Application.Interfaces

This commit is contained in:
beo3000 2025-12-22 22:00:49 +01:00
parent 57146a382a
commit f05ee0a662
7 changed files with 358 additions and 13 deletions

View File

@ -326,7 +326,7 @@ NavMenu.razor:
| ✓ | A1 | Foundation | Repository Interfaces | 5 Interface-Dateien |
| ✓ | A2 | Foundation | Repository Implementations | 5 Repository-Dateien |
| ✓ | A3 | Foundation | DTOs | 5 DTO-Dateien |
| | A4 | Foundation | Service Interfaces | 5 Service-Interface-Dateien |
| | A4 | Foundation | Service Interfaces | 5 Service-Interface-Dateien |
| ☐ | A5 | Foundation | Service Implementations | 5 Service-Dateien |
| ☐ | A6 | Foundation | AutoMapper Profiles | 5 Mapping-Dateien |
| ☐ | A7 | Foundation | DI Registration | 2 DI-Dateien ändern |

View File

@ -0,0 +1,48 @@
using Koogle.Application.DTOs;
namespace Koogle.Application.Interfaces;
/// <summary>
/// Service interface for managing club operations.
/// </summary>
public interface IClubService
{
/// <summary>
/// Retrieves all clubs. Requires SuperAdmin role.
/// </summary>
/// <param name="ct">Cancellation token.</param>
/// <returns>A list of all clubs.</returns>
Task<List<ClubDto>> GetAllAsync(CancellationToken ct = default);
/// <summary>
/// Retrieves a club by its unique identifier.
/// </summary>
/// <param name="id">The unique identifier of the club.</param>
/// <param name="ct">Cancellation token.</param>
/// <returns>The club if found; otherwise, null.</returns>
Task<ClubDto?> GetByIdAsync(Guid id, CancellationToken ct = default);
/// <summary>
/// Creates a new club. Requires SuperAdmin role.
/// </summary>
/// <param name="dto">The club creation data.</param>
/// <param name="ct">Cancellation token.</param>
/// <returns>The created club.</returns>
Task<ClubDto> CreateAsync(CreateClubDto dto, CancellationToken ct = default);
/// <summary>
/// Updates an existing club. Requires SuperAdmin role.
/// </summary>
/// <param name="dto">The club update data.</param>
/// <param name="ct">Cancellation token.</param>
/// <returns>The updated club.</returns>
Task<ClubDto> UpdateAsync(UpdateClubDto dto, CancellationToken ct = default);
/// <summary>
/// Deletes a club. Requires SuperAdmin role.
/// </summary>
/// <param name="id">The unique identifier of the club to delete.</param>
/// <param name="ct">Cancellation token.</param>
/// <returns>True if deleted successfully; otherwise, false.</returns>
Task<bool> DeleteAsync(Guid id, CancellationToken ct = default);
}

View File

@ -1,14 +1,80 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Koogle.Application.DTOs;
namespace Koogle.Application.Interfaces
namespace Koogle.Application.Interfaces;
/// <summary>
/// Service interface for managing game day operations.
/// </summary>
public interface IDayService
{
public interface IDayService
{
Task<PagedResultDto<DaySummaryDto>> GetAllAsync(DayFilterDto filter, CancellationToken cancellationToken = default);
}
/// <summary>
/// Retrieves all days for the current club context with optional filtering.
/// </summary>
/// <param name="filter">Optional filter criteria.</param>
/// <param name="ct">Cancellation token.</param>
/// <returns>A paged result of day summaries.</returns>
Task<PagedResultDto<DaySummaryDto>> GetAllAsync(DayFilterDto? filter = null, CancellationToken ct = default);
/// <summary>
/// Retrieves a day by its unique identifier with full details.
/// </summary>
/// <param name="id">The unique identifier of the day.</param>
/// <param name="ct">Cancellation token.</param>
/// <returns>The day if found; otherwise, null.</returns>
Task<DayDto?> GetByIdAsync(Guid id, CancellationToken ct = default);
/// <summary>
/// Creates a new game day in the current club context.
/// </summary>
/// <param name="dto">The day creation data.</param>
/// <param name="ct">Cancellation token.</param>
/// <returns>The created day.</returns>
Task<DayDto> CreateAsync(CreateDayDto dto, CancellationToken ct = default);
/// <summary>
/// Updates an existing game day.
/// </summary>
/// <param name="dto">The day update data.</param>
/// <param name="ct">Cancellation token.</param>
/// <returns>The updated day.</returns>
Task<DayDto> UpdateAsync(UpdateDayDto dto, CancellationToken ct = default);
/// <summary>
/// Deletes a game day.
/// </summary>
/// <param name="id">The unique identifier of the day to delete.</param>
/// <param name="ct">Cancellation token.</param>
/// <returns>True if deleted successfully; otherwise, false.</returns>
Task<bool> DeleteAsync(Guid id, CancellationToken ct = default);
/// <summary>
/// Retrieves the active day (today) for the current club if exists.
/// </summary>
/// <param name="ct">Cancellation token.</param>
/// <returns>The active day if found; otherwise, null.</returns>
Task<DayDto?> GetActiveDayAsync(CancellationToken ct = default);
/// <summary>
/// Adds a participant to a game day.
/// </summary>
/// <param name="dto">The participant addition data.</param>
/// <param name="ct">Cancellation token.</param>
/// <returns>The updated day.</returns>
Task<DayDto> AddParticipantAsync(AddDayParticipantDto dto, CancellationToken ct = default);
/// <summary>
/// Removes a participant from a game day.
/// </summary>
/// <param name="dto">The participant removal data.</param>
/// <param name="ct">Cancellation token.</param>
/// <returns>The updated day.</returns>
Task<DayDto> RemoveParticipantAsync(RemoveDayParticipantDto dto, CancellationToken ct = default);
/// <summary>
/// Changes the status of a game day following the workflow: New → Started → Closed.
/// </summary>
/// <param name="id">The unique identifier of the day.</param>
/// <param name="ct">Cancellation token.</param>
/// <returns>The updated day.</returns>
Task<DayDto> AdvanceStatusAsync(Guid id, CancellationToken ct = default);
}

View File

@ -0,0 +1,55 @@
using Koogle.Application.DTOs;
namespace Koogle.Application.Interfaces;
/// <summary>
/// Service interface for managing expense template operations.
/// </summary>
public interface IExpenseService
{
/// <summary>
/// Retrieves all expense templates for the current club context.
/// </summary>
/// <param name="ct">Cancellation token.</param>
/// <returns>A list of expense templates.</returns>
Task<List<ExpenseDto>> GetAllAsync(CancellationToken ct = default);
/// <summary>
/// Retrieves an expense template by its unique identifier.
/// </summary>
/// <param name="id">The unique identifier of the expense.</param>
/// <param name="ct">Cancellation token.</param>
/// <returns>The expense if found; otherwise, null.</returns>
Task<ExpenseDto?> GetByIdAsync(Guid id, CancellationToken ct = default);
/// <summary>
/// Creates a new expense template in the current club context.
/// </summary>
/// <param name="dto">The expense creation data.</param>
/// <param name="ct">Cancellation token.</param>
/// <returns>The created expense.</returns>
Task<ExpenseDto> CreateAsync(CreateExpenseDto dto, CancellationToken ct = default);
/// <summary>
/// Updates an existing expense template.
/// </summary>
/// <param name="dto">The expense update data.</param>
/// <param name="ct">Cancellation token.</param>
/// <returns>The updated expense.</returns>
Task<ExpenseDto> UpdateAsync(UpdateExpenseDto dto, CancellationToken ct = default);
/// <summary>
/// Deletes an expense template.
/// </summary>
/// <param name="id">The unique identifier of the expense to delete.</param>
/// <param name="ct">Cancellation token.</param>
/// <returns>True if deleted successfully; otherwise, false.</returns>
Task<bool> DeleteAsync(Guid id, CancellationToken ct = default);
/// <summary>
/// Retrieves all one-click expense templates for quick access.
/// </summary>
/// <param name="ct">Cancellation token.</param>
/// <returns>A list of one-click expenses.</returns>
Task<List<ExpenseSummaryDto>> GetOneClickExpensesAsync(CancellationToken ct = default);
}

View File

@ -0,0 +1,81 @@
using Koogle.Application.DTOs;
namespace Koogle.Application.Interfaces;
/// <summary>
/// Service interface for managing person expense assignment operations.
/// </summary>
public interface IPersonExpenseService
{
/// <summary>
/// Retrieves all expenses for a specific day.
/// </summary>
/// <param name="dayId">The unique identifier of the day.</param>
/// <param name="ct">Cancellation token.</param>
/// <returns>A list of person expenses for the day.</returns>
Task<List<PersonExpenseDto>> GetByDayIdAsync(Guid dayId, CancellationToken ct = default);
/// <summary>
/// Retrieves all expenses for a specific person.
/// </summary>
/// <param name="personId">The unique identifier of the person.</param>
/// <param name="ct">Cancellation token.</param>
/// <returns>A list of person expenses.</returns>
Task<List<PersonExpenseDto>> GetByPersonIdAsync(Guid personId, CancellationToken ct = default);
/// <summary>
/// Retrieves a person expense by its unique identifier.
/// </summary>
/// <param name="id">The unique identifier of the person expense.</param>
/// <param name="ct">Cancellation token.</param>
/// <returns>The person expense if found; otherwise, null.</returns>
Task<PersonExpenseDto?> GetByIdAsync(Guid id, CancellationToken ct = default);
/// <summary>
/// Creates a new person expense assignment.
/// </summary>
/// <param name="dto">The person expense creation data.</param>
/// <param name="ct">Cancellation token.</param>
/// <returns>The created person expense.</returns>
Task<PersonExpenseDto> CreateAsync(CreatePersonExpenseDto dto, CancellationToken ct = default);
/// <summary>
/// Creates inverse expenses (charged to all participants except one person).
/// </summary>
/// <param name="dto">The inverse expense creation data.</param>
/// <param name="ct">Cancellation token.</param>
/// <returns>A list of created person expenses.</returns>
Task<List<PersonExpenseDto>> CreateInverseAsync(CreateInversePersonExpenseDto dto, CancellationToken ct = default);
/// <summary>
/// Updates the status of a person expense (Open/Done).
/// </summary>
/// <param name="dto">The status update data.</param>
/// <param name="ct">Cancellation token.</param>
/// <returns>The updated person expense.</returns>
Task<PersonExpenseDto> UpdateStatusAsync(UpdatePersonExpenseStatusDto dto, CancellationToken ct = default);
/// <summary>
/// Deletes a person expense. Only allowed when day status is New or Started.
/// </summary>
/// <param name="id">The unique identifier of the person expense to delete.</param>
/// <param name="ct">Cancellation token.</param>
/// <returns>True if deleted successfully; otherwise, false.</returns>
Task<bool> DeleteAsync(Guid id, CancellationToken ct = default);
/// <summary>
/// Gets the evaluation summary for a specific day.
/// </summary>
/// <param name="dayId">The unique identifier of the day.</param>
/// <param name="ct">Cancellation token.</param>
/// <returns>The day evaluation summary.</returns>
Task<DayEvaluationDto> GetDayEvaluationAsync(Guid dayId, CancellationToken ct = default);
/// <summary>
/// Gets the evaluation summary for a specific person.
/// </summary>
/// <param name="personId">The unique identifier of the person.</param>
/// <param name="ct">Cancellation token.</param>
/// <returns>The person evaluation summary.</returns>
Task<PersonEvaluationSummaryDto> GetPersonEvaluationAsync(Guid personId, CancellationToken ct = default);
}

View File

@ -0,0 +1,62 @@
using Koogle.Application.DTOs;
namespace Koogle.Application.Interfaces;
/// <summary>
/// Service interface for managing person (member/guest) operations.
/// </summary>
public interface IPersonService
{
/// <summary>
/// Retrieves all persons for the current club context.
/// </summary>
/// <param name="ct">Cancellation token.</param>
/// <returns>A list of persons in the current club.</returns>
Task<List<PersonDto>> GetAllAsync(CancellationToken ct = default);
/// <summary>
/// Retrieves a person by its unique identifier.
/// </summary>
/// <param name="id">The unique identifier of the person.</param>
/// <param name="ct">Cancellation token.</param>
/// <returns>The person if found; otherwise, null.</returns>
Task<PersonDto?> GetByIdAsync(Guid id, CancellationToken ct = default);
/// <summary>
/// Creates a new person in the current club context.
/// </summary>
/// <param name="dto">The person creation data.</param>
/// <param name="ct">Cancellation token.</param>
/// <returns>The created person.</returns>
Task<PersonDto> CreateAsync(CreatePersonDto dto, CancellationToken ct = default);
/// <summary>
/// Updates an existing person.
/// </summary>
/// <param name="dto">The person update data.</param>
/// <param name="ct">Cancellation token.</param>
/// <returns>The updated person.</returns>
Task<PersonDto> UpdateAsync(UpdatePersonDto dto, CancellationToken ct = default);
/// <summary>
/// Deletes a person.
/// </summary>
/// <param name="id">The unique identifier of the person to delete.</param>
/// <param name="ct">Cancellation token.</param>
/// <returns>True if deleted successfully; otherwise, false.</returns>
Task<bool> DeleteAsync(Guid id, CancellationToken ct = default);
/// <summary>
/// Retrieves all members (excluding guests) for the current club.
/// </summary>
/// <param name="ct">Cancellation token.</param>
/// <returns>A list of members.</returns>
Task<List<PersonSummaryDto>> GetMembersAsync(CancellationToken ct = default);
/// <summary>
/// Retrieves all guests for the current club.
/// </summary>
/// <param name="ct">Cancellation token.</param>
/// <returns>A list of guests.</returns>
Task<List<PersonSummaryDto>> GetGuestsAsync(CancellationToken ct = default);
}

View File

@ -27,7 +27,7 @@ namespace Koogle.Application.Services
private readonly ICurrentUserService _currentUserService = currentUserService;
private readonly IAuthorizationService _authorizationService = authorizationService;
public async Task<PagedResultDto<DaySummaryDto>> GetAllAsync(DayFilterDto filter, CancellationToken cancellationToken = default)
public async Task<PagedResultDto<DaySummaryDto>> GetAllAsync(DayFilterDto? filter = null, CancellationToken cancellationToken = default)
{
await using var context = await contextFactory.CreateDbContextAsync(cancellationToken);
@ -38,7 +38,8 @@ namespace Koogle.Application.Services
.AsQueryable();
// Filter anwenden
query = ApplyFilters(query, filter);
if (filter != null)
query = ApplyFilters(query, filter);
// Gesamtanzahl ermitteln
var totalCount = await query.CountAsync(cancellationToken);
@ -130,5 +131,37 @@ namespace Koogle.Application.Services
return query;
}
/// <inheritdoc />
public Task<DayDto?> GetByIdAsync(Guid id, CancellationToken ct = default)
=> throw new NotImplementedException("Will be implemented in Phase A5");
/// <inheritdoc />
public Task<DayDto> CreateAsync(CreateDayDto dto, CancellationToken ct = default)
=> throw new NotImplementedException("Will be implemented in Phase A5");
/// <inheritdoc />
public Task<DayDto> UpdateAsync(UpdateDayDto dto, CancellationToken ct = default)
=> throw new NotImplementedException("Will be implemented in Phase A5");
/// <inheritdoc />
public Task<bool> DeleteAsync(Guid id, CancellationToken ct = default)
=> throw new NotImplementedException("Will be implemented in Phase A5");
/// <inheritdoc />
public Task<DayDto?> GetActiveDayAsync(CancellationToken ct = default)
=> throw new NotImplementedException("Will be implemented in Phase A5");
/// <inheritdoc />
public Task<DayDto> AddParticipantAsync(AddDayParticipantDto dto, CancellationToken ct = default)
=> throw new NotImplementedException("Will be implemented in Phase A5");
/// <inheritdoc />
public Task<DayDto> RemoveParticipantAsync(RemoveDayParticipantDto dto, CancellationToken ct = default)
=> throw new NotImplementedException("Will be implemented in Phase A5");
/// <inheritdoc />
public Task<DayDto> AdvanceStatusAsync(Guid id, CancellationToken ct = default)
=> throw new NotImplementedException("Will be implemented in Phase A5");
}
}