public void RegisterInstance(CSComponent component) { Instances.Add(component); if (StartMethod != null) { StartList.Add(component); } }
public async Task <ActionResult> Save(int raceId, int runNumber, [FromBody] IEnumerable <StartListDto> startList) { List <StartList> dbStartList = new List <StartList>(); foreach (var startListItem in startList) { StartList dbStartListItem = this.mapper.Map <StartList>(startListItem); dbStartList.Add(this.mapper.Map <StartList>(startListItem)); } var result = await this.startListLogic.SaveAsync(raceId, runNumber, dbStartList); return(result.Match( success => this.StatusCode(200, success.Id), validationError => this.StatusCode(400, validationError.Errors), error => this.StatusCode(500, error.ErrorCode))); }
public void ValidateDefaultStartListTest() { // Arrange var validators = new StartListValidator(); var skier = new StartList(); // Act var result = validators.Validate(skier); // Assert Assert.False(result.IsValid); Assert.Equal(4, result.Errors.Count); Assert.Equal(ErrorCode.GreaterThanOrEqual, result.ErrorCodeFor(nameof(StartList.StartNumber))); Assert.Equal(ErrorCode.GreaterThanOrEqual, result.ErrorCodeFor(nameof(StartList.RunNumber))); Assert.Equal(ErrorCode.ForeignKey, result.ErrorCodeFor(nameof(StartList.SkierId))); Assert.Equal(ErrorCode.ForeignKey, result.ErrorCodeFor(nameof(StartList.RaceId))); }
public async Task SetupAsync() { try { if (!_eventsSetup) { SetupRaceEvents(); } _currentSkier = await _activeRaceService.GetCurrentSkier(RaceState.Race.Id); await LoadStartList(); await CurrentSkierViewModel.InitializeAsync(); await RankingViewModel.InitializeAsync(); } catch (Exception) { MessageBoxUtil.Error("Fehler beim Laden der Daten"); } }
public static StartListState GetStartListState( this StartList startList, IEnumerable <RaceData> raceData, int sensorAmount, int runningStartListId) { if (startList.IsDisqualified) { return(StartListState.Disqualified); } if (startList.Id == runningStartListId) { return(StartListState.Running); } if (raceData.Any(d => d.SensorId == sensorAmount)) { return(StartListState.Done); } return(StartListState.NotStarted); }
private void SetupCommands() { ReadyTrackCommand = new AsyncCommand(ReadyTrack, () => (_currentSkier == null || _currentSkier != null && (_currentSkier.StartStateId == (int)StartState.Finished || _currentSkier.StartStateId == (int)StartState.Disqualified)) && StartList.Any()); CancelSkierCommand = new AsyncCommand <int>(async skierId => await CancelSkier(skierId)); CancelRaceCommand = new AsyncCommand(CancelRace, () => RaceState.Race.RaceStateId == (int)Dal.Domain.Enums.RaceState.Running); EndRaceCommand = new AsyncCommand( EndRace, () => (_currentSkier == null || _currentSkier.StartStateId != (int)Dal.Domain.Enums.RaceState.Finished) && StartList.Count == 0 && RaceState.Race.RaceStateId == (int)Dal.Domain.Enums.RaceState.Running); DisqualifyCurrentSkierCommand = new AsyncCommand( async() => await _activeRaceControlService.DisqualifyCurrentSkier(), () => _currentSkier != null && _currentSkier.StartStateId == (int)StartState.Running); DisqualifyLateCommand = new AsyncCommand(() => _activeRaceControlService.DisqualifyFinishedSkier( RankingViewModel.SelectedRaceRanking.StartList.SkierId), () => { var selectedRanking = RankingViewModel .SelectedRaceRanking; return(selectedRanking != null && selectedRanking.StartList.StartStateId == (int)StartState.Finished); }); }
public void Update(Object[] args) { if (StartMethod != null) { foreach (var instance in StartList) { var node = instance.Node; if (node != null && node.IsEnabled()) { if (node.Scene != null) { StartMethod.Invoke(instance, null); } } } // TODO: need to handle delayed starts when node isn't enabled StartList.Clear(); } if (UpdateMethod != null) { foreach (var instance in Instances) { bool remove = false; var node = instance.Node; // TODO: Ideally we want to remove disabled instances, // and re-add them when re-enabled if (node != null /*&& node.IsEnabled()*/) { if (node.Scene != null) { if (node.IsEnabled()) { UpdateMethod.Invoke(instance, args); } } else { remove = true; } } else { remove = true; } if (remove) { RemoveList.Add(instance); } } } foreach (var instance in RemoveList) { Instances.Remove(instance); } RemoveList.Clear(); }
private async Task LoadStartList() => StartList.Repopulate(await _activeRaceService.GetRemainingStartList(RaceState.Race.Id));
public static StartListForRaceDto FromStartList(StartList sl) => new StartListForRaceDto( sl.StartNumber, sl.Skier, sl.StartStateId );