Add Ping backend
.NET 10 solution for Ping, a Discord style chat app: Domain, Application and Infrastructure projects plus the Api host. SignalR for chat and presence, LiveKit for call tokens, EF Core on Postgres, S3 compatible storage for attachments, and OIDC auth shared with the Musify Zitadel instance. Includes the Compose stack for local development.
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
using ErrorOr;
|
||||
using Mediator;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Ping.Application.Contracts;
|
||||
using Ping.Application.Users.Responses;
|
||||
|
||||
namespace Ping.Application.Users
|
||||
{
|
||||
public record GetUserByIdQuery(long Id) : IQuery<ErrorOr<UserResponse>>;
|
||||
|
||||
public class GetUserByIdQueryHandler(IDatabase database)
|
||||
: IQueryHandler<GetUserByIdQuery, ErrorOr<UserResponse>>
|
||||
{
|
||||
public async ValueTask<ErrorOr<UserResponse>> Handle(GetUserByIdQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var user = await database.Users.AsNoTracking().FirstOrDefaultAsync(u => u.Id == request.Id, cancellationToken);
|
||||
return user is null
|
||||
? Error.NotFound(description: $"User {request.Id} not found")
|
||||
: UserResponse.FromEntity(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user