chatbot/Chatbot.Api.Application/CommandHandlers/CloseChatHandler.cs

26 lines
754 B
C#
Raw Normal View History

2020-06-07 02:38:52 +03:00
using Chatbot.Api.Application.Commands;
using Chatbot.Api.Application.Events;
using Chatbot.Api.Domain.Repositories;
using MediatR;
using System.Threading;
using System.Threading.Tasks;
namespace Chatbot.Api.Application.CommandHandlers
{
public class CloseChatHandler : IRequestHandler<CloseChat, ChatClosed>
{
private readonly IChatRepository _chatRepository;
public CloseChatHandler(IChatRepository chatRepository)
{
_chatRepository = chatRepository;
}
public async Task<ChatClosed> Handle(CloseChat request, CancellationToken cancellationToken)
{
await _chatRepository.CloseChat(request.ChatId);
return new ChatClosed(request.ChatId);
}
}
}