private async Task UpdateMatch(StartMatchUpdateCommand command, CancellationToken cancellationToken)
        {
            _logger.LogInformation("Starting video conversion for match ({0})", command.MatchId);

            try
            {
                var trimResult = await _videoConverter.TrimVideoAsync(command.MatchId.ToString(),
                                                                      command.Video,
                                                                      command.Start,
                                                                      command.End);

                var updateCommand = new UpdateMatchCommand
                {
                    MatchId = command.MatchId,
                    UserId  = command.UserId,
                    Thumb   = trimResult.Thumb,
                    Video   = trimResult.Video,
                    Move    = command.Move,
                };

                using (var scope = _serviceProvider.CreateScope())
                {
                    var mediator = scope.ServiceProvider.GetRequiredService <IMediator>();
                    await mediator.Send(updateCommand, cancellationToken);

                    var notificationSender =
                        scope.ServiceProvider.GetRequiredService <IMatchUpdaterNotifications>();
                    await notificationSender.NotifyMatchUpdated(command.UserId, command.MatchId);
                }
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Failed to update match ({0})", command.MatchId);
            }
        }
        public async Task <IActionResult> UpdateMatch(int matchId, [FromBody] StartMatchUpdateCommand command)
        {
            command.MatchId = matchId;
            command.UserId  = UserId;

            var response = await Mediator.Send(command);

            return(Ok(response));
        }
 public void QueueUpdate(StartMatchUpdateCommand command)
 {
     _updateMatchQueue.Enqueue(ct => UpdateMatch(command, ct));
     _signal.Release();
 }