using Baya.Application.Contracts.Holidays;
using Baya.Application.Models.Common;
using Mediator;

namespace Baya.Application.Features.Holidays.Commands.UpsertHoliday;

internal sealed class UpsertHolidayCommandHandler(IHolidayCalendar holidayCalendar)
    : IRequestHandler<UpsertHolidayCommand, OperationResult<bool>>
{
    public async ValueTask<OperationResult<bool>> Handle(UpsertHolidayCommand request, CancellationToken cancellationToken)
    {
        await holidayCalendar.UpsertAsync(request.HolidayDate, request.NameFa, request.Type, request.IsBankClosed, cancellationToken);
        return OperationResult<bool>.SuccessResult(true);
    }
}
