IAppUnitOfWork.cs
3,629 bytes
| 1 | using SplitApp.Modules.Expenses.Domain.Entities; |
|---|---|
| 2 | using SplitApp.Modules.Trips.Domain.Entities; |
| 3 | using SplitApp.Modules.Users.Domain.Entities; |
| 4 | using SplitApp.Shared.Kernel.Domain; |
| 5 | using SplitApp.Shared.Kernel.Persistence; |
| 6 | |
| 7 | namespace SplitApp.WebApp.Application.Contracts; |
| 8 | |
| 9 | /// <summary> |
| 10 | /// Composition-root unit-of-work facade. Aggregates the three module DbContexts |
| 11 | /// so legacy phase 2 BLL services (lifted into WebApp/Application) keep working. |
| 12 | /// Modules themselves never see this — they own their own UoWs. |
| 13 | /// </summary> |
| 14 | public interface IAppUnitOfWork : IUnitOfWork |
| 15 | { |
| 16 | ITripRepository Trips { get; } |
| 17 | IExpenseRepository Expenses { get; } |
| 18 | ITripParticipantRepository TripParticipants { get; } |
| 19 | ITripInvitationRepository TripInvitations { get; } |
| 20 | ISettlementPlanRepository SettlementPlans { get; } |
| 21 | ISettlementPaymentRepository SettlementPayments { get; } |
| 22 | ITripPollRepository TripPolls { get; } |
| 23 | ITripWishlistItemRepository TripWishlistItems { get; } |
| 24 | ISplitPresetRepository SplitPresets { get; } |
| 25 | IBudgetCategoryRepository BudgetCategories { get; } |
| 26 | IRefreshTokenRepository RefreshTokens { get; } |
| 27 | IUserRepository Users { get; } |
| 28 | IBaseRepository<TEntity> GetRepository<TEntity>() where TEntity : class, IBaseEntity; |
| 29 | } |
| 30 | |
| 31 | public interface ITripRepository : IBaseRepository<Trip> |
| 32 | { |
| 33 | Task<IEnumerable<Trip>> GetUserTripsAsync(Guid userId); |
| 34 | Task<Trip?> GetByIdWithDetailsAsync(Guid id); |
| 35 | } |
| 36 | |
| 37 | public interface IExpenseRepository : IBaseRepository<Expense> |
| 38 | { |
| 39 | Task<IEnumerable<Expense>> GetByTripIdAsync(Guid tripId); |
| 40 | Task<Expense?> GetByIdWithDetailsAsync(Guid id); |
| 41 | } |
| 42 | |
| 43 | public interface ITripParticipantRepository : IBaseRepository<TripParticipant> |
| 44 | { |
| 45 | Task<bool> IsParticipantAsync(Guid tripId, Guid userId); |
| 46 | Task<bool> IsOrganizerAsync(Guid tripId, Guid userId); |
| 47 | Task<IEnumerable<TripParticipant>> GetByTripIdAsync(Guid tripId); |
| 48 | } |
| 49 | |
| 50 | public interface ITripInvitationRepository : IBaseRepository<TripInvitation> |
| 51 | { |
| 52 | Task<TripInvitation?> GetByTokenAsync(string token); |
| 53 | Task<IEnumerable<TripInvitation>> GetPendingByTripIdAsync(Guid tripId); |
| 54 | } |
| 55 | |
| 56 | public interface ISettlementPlanRepository : IBaseRepository<SettlementPlan> |
| 57 | { |
| 58 | Task<SettlementPlan?> GetLatestByTripIdAsync(Guid tripId); |
| 59 | Task DeletePlanWithPaymentsAsync(Guid planId); |
| 60 | } |
| 61 | |
| 62 | public interface ISettlementPaymentRepository : IBaseRepository<SettlementPayment> |
| 63 | { |
| 64 | } |
| 65 | |
| 66 | public interface ITripPollRepository : IBaseRepository<TripPoll> |
| 67 | { |
| 68 | Task<IEnumerable<TripPoll>> GetByTripIdAsync(Guid tripId); |
| 69 | Task<TripPoll?> GetByIdWithDetailsAsync(Guid id); |
| 70 | } |
| 71 | |
| 72 | public interface ITripWishlistItemRepository : IBaseRepository<TripWishlistItem> |
| 73 | { |
| 74 | Task<IEnumerable<TripWishlistItem>> GetByTripIdAsync(Guid tripId); |
| 75 | } |
| 76 | |
| 77 | public interface ISplitPresetRepository : IBaseRepository<SplitPreset> |
| 78 | { |
| 79 | Task<IEnumerable<SplitPreset>> GetByTripIdAsync(Guid tripId); |
| 80 | } |
| 81 | |
| 82 | public interface IBudgetCategoryRepository : IBaseRepository<BudgetCategory> |
| 83 | { |
| 84 | Task<IEnumerable<BudgetCategory>> GetByTripIdAsync(Guid tripId); |
| 85 | } |
| 86 | |
| 87 | public interface IRefreshTokenRepository : IBaseRepository<AppRefreshToken> |
| 88 | { |
| 89 | Task<IEnumerable<AppRefreshToken>> GetUserActiveTokensAsync(Guid userId, string refreshTokenValue); |
| 90 | Task<IEnumerable<AppRefreshToken>> GetUserTokensByValueAsync(Guid userId, string refreshTokenValue); |
| 91 | Task<int> RemoveExpiredForUserAsync(Guid userId); |
| 92 | void Remove(AppRefreshToken token); |
| 93 | } |
| 94 | |
| 95 | public interface IUserRepository : IBaseRepository<AppUser> |
| 96 | { |
| 97 | Task<int> CountAsync(); |
| 98 | Task<IEnumerable<AppUser>> GetRecentAsync(int take); |
| 99 | Task<AppUser?> GetByIdWithRefreshTokensAsync(Guid userId); |
| 100 | } |
| 101 | |