This commit is contained in:
Veljko Tosic
2026-02-16 18:18:58 +01:00
parent 5d148db4da
commit f2e38f0b09
9 changed files with 84 additions and 18 deletions

View File

@@ -2,4 +2,4 @@ using AipsCore.Application.Abstract.Query;
namespace AipsCore.Application.Models.Whiteboard.Query.GetRecentWhiteboards;
public record GetRecentWhiteboardsQuery(string UserId): IQuery<ICollection<Infrastructure.Persistence.Whiteboard.Whiteboard>>;
public record GetRecentWhiteboardsQuery: IQuery<ICollection<Infrastructure.Persistence.Whiteboard.Whiteboard>>;

View File

@@ -1,4 +1,5 @@
using AipsCore.Application.Abstract.Query;
using AipsCore.Application.Abstract.UserContext;
using AipsCore.Infrastructure.Persistence.Db;
using Microsoft.EntityFrameworkCore;
@@ -7,20 +8,24 @@ namespace AipsCore.Application.Models.Whiteboard.Query.GetRecentWhiteboards;
public class GetRecentWhiteboardsQueryHandler : IQueryHandler<GetRecentWhiteboardsQuery, ICollection<Infrastructure.Persistence.Whiteboard.Whiteboard>>
{
private readonly AipsDbContext _context;
private readonly IUserContext _userContext;
public GetRecentWhiteboardsQueryHandler(AipsDbContext context)
public GetRecentWhiteboardsQueryHandler(AipsDbContext context, IUserContext userContext)
{
_context = context;
_userContext = userContext;
}
public async Task<ICollection<Infrastructure.Persistence.Whiteboard.Whiteboard>> Handle(GetRecentWhiteboardsQuery query, CancellationToken cancellationToken = default)
{
return await GetQuery(query.UserId).ToListAsync(cancellationToken);
var userId = _userContext.GetCurrentUserId().IdValue;
return await GetQuery(userId).ToListAsync(cancellationToken);
}
private IQueryable<Infrastructure.Persistence.Whiteboard.Whiteboard> GetQuery(string userId)
{
Guid userIdGuid = Guid.Parse(userId);
var userIdGuid = Guid.Parse(userId);
return _context.WhiteboardMemberships
.Include(m => m.Whiteboard)

View File

@@ -0,0 +1,5 @@
using AipsCore.Application.Abstract.Query;
namespace AipsCore.Application.Models.Whiteboard.Query.GetWhiteboardHistory;
public record GetWhiteboardHistoryQuery : IQuery<ICollection<Infrastructure.Persistence.Whiteboard.Whiteboard>>;

View File

@@ -0,0 +1,28 @@
using AipsCore.Application.Abstract.Query;
using AipsCore.Application.Abstract.UserContext;
using AipsCore.Infrastructure.Persistence.Db;
using Microsoft.EntityFrameworkCore;
namespace AipsCore.Application.Models.Whiteboard.Query.GetWhiteboardHistory;
public class GetWhiteboardHistoryQueryHandler
: IQueryHandler<GetWhiteboardHistoryQuery, ICollection<Infrastructure.Persistence.Whiteboard.Whiteboard>>
{
private readonly AipsDbContext _context;
private readonly IUserContext _userContext;
public GetWhiteboardHistoryQueryHandler(AipsDbContext context, IUserContext userContext)
{
_context = context;
_userContext = userContext;
}
public async Task<ICollection<Infrastructure.Persistence.Whiteboard.Whiteboard>> Handle(GetWhiteboardHistoryQuery query, CancellationToken cancellationToken = default)
{
var userIdGuid = new Guid(_userContext.GetCurrentUserId().IdValue);
return await _context.Whiteboards
.Where(w => w.OwnerId == userIdGuid)
.ToListAsync(cancellationToken);
}
}