forked from mtusi2026/mtusi2026lab2
ЛР 2: PostgreSQL, сессии, Redis и исследование
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
using Messenger.Api.Contracts;
|
||||
using Messenger.Api.Data;
|
||||
|
||||
namespace Messenger.Api.Services;
|
||||
|
||||
public sealed class ChatService(AppDatabase database)
|
||||
{
|
||||
public async Task<ChatDto?> CreateAsync(string title, List<Guid> memberIds) =>
|
||||
(await database.CreateChatAsync(title, memberIds))?.ToDto();
|
||||
|
||||
public async Task<ChatDto?> FindForMemberAsync(Guid chatId, Guid userId) =>
|
||||
(await database.FindChatForMemberAsync(chatId, userId))?.ToDto();
|
||||
|
||||
public async Task<List<ChatDto>> ListAsync(Guid userId, DateTime? cursorTime, Guid? cursorId, int count) =>
|
||||
(await database.ListChatsAsync(userId, cursorTime, cursorId, count)).Select(chat => chat.ToDto()).ToList();
|
||||
}
|
||||
Reference in New Issue
Block a user