public async Task <TrainingDTO> GetCurrentTrainingForTeamAsync(int teamId) { Training training = await trainings.GetCurrentTrainingForTeamAsync(teamId); if (training == null) { throw new NotFoundException("Team doesn't have any trainings!"); } DateTime trainingEnd = await trainings.GetTrainingEndTimeAsync(training.Id); if ((DateTime.UtcNow - trainingEnd).Minutes >= idlenessMinutesForNewTraining) { await trainings.StopCurrentTrainingForTeamAsync(teamId); throw new NotFoundException("The training is over"); } return(new TrainingDTO { Id = training.Id, TeamId = training.TeamId, BeginTime = training.BeginTime }); }