using MediatR;
using Microsoft.Extensions.Logging;
using Netmash.Extensions.Caching.Services;
using NetworkResurrector.Api.PublishedLanguage.Commands;
using NetworkResurrector.Api.PublishedLanguage.Dto;
using System.Threading;
using System.Threading.Tasks;

namespace NetworkResurrector.Api.Application.CommandHandlers
{
    internal class ResetCacheHandler : IRequestHandler<ResetCache, CommandResult>
    {
        private readonly ILogger<CancelMachineHandler> _logger;
        private readonly ICacheService _cache;

        public ResetCacheHandler(ILogger<CancelMachineHandler> logger, ICacheService cache)
        {
            _logger=logger;
            _cache=cache;
        }

        public async Task<CommandResult> Handle(ResetCache request, CancellationToken cancellationToken)
        {
            _cache.Reset();
            return await Task.FromResult(new CommandResult());
        }
    }
}
