public Guid StartTrack([FromBody] TrackRecordViewModel model)
        {
            var user = _identityService.Get(_userContextProvider.GetContextUserName());

            model.Id = _service.Create(MapTrackRecordViewModelToTrackRecord(model), user.Id);
            return(model.Id);
        }
Esempio n. 2
0
        private void OpenTracksRecords()
        {
            if (_currentSimulatorRecords == null)
            {
                return;
            }

            var trackRecordsOrdered       = _currentSimulatorRecords.TrackRecords.OrderBy(x => x.TrackName);
            var simulatorRecordsViewModel = _viewModelFactory.Create <SimulatorRecordsViewModel>();

            simulatorRecordsViewModel.Title = "Track Records for " + _currentSimulatorRecords.SimulatorName + " (" + (_showRecordsForSession ? _currentSessionType.ToString() : "All Sessions") + ")";
            List <TrackRecordViewModel> trackRecords = new List <TrackRecordViewModel>(_currentSimulatorRecords.TrackRecords.Count);

            foreach (TrackRecord trackRecord in trackRecordsOrdered)
            {
                RecordEntryDto record = GetCorrectRecordEntry(trackRecord.OverallRecord);
                if (record == null)
                {
                    continue;
                }
                TrackRecordViewModel newViewModel = _viewModelFactory.Create <TrackRecordViewModel>();
                newViewModel.CarName       = record.CarName;
                newViewModel.ClassName     = record.CarClass;
                newViewModel.BestTime      = record.LapTime;
                newViewModel.RecordSetDate = record.RecordDate;
                newViewModel.TrackName     = trackRecord.TrackName;
                newViewModel.SessionType   = record.SessionType.ToString();
                trackRecords.Add(newViewModel);
            }

            simulatorRecordsViewModel.ChildViewModels = trackRecords;
            _windowService.OpenWindow(simulatorRecordsViewModel, simulatorRecordsViewModel.Title, WindowState.Normal, SizeToContent.WidthAndHeight, WindowStartupLocation.CenterOwner);
        }
        private static TrackRecord MapTrackRecordViewModelToTrackRecord(TrackRecordViewModel viewModel)
        {
            var pattern = new TrackRecord
            {
                IsWorking    = viewModel.IsWorking,
                IsCancelled  = viewModel.IsCancelled,
                PatternValue = viewModel.Domain,
                StartDate    = viewModel.StartTime,
            };

            return(pattern);
        }
        private static TrackRecordViewModel MapTrackRecordToTrackRecordViewModel(TrackRecord entity)
        {
            var pattern = new TrackRecordViewModel
            {
                Id          = entity.Id,
                CreateDate  = entity.CreateDate,
                UpdateDate  = entity.UpdateDate,
                IsCancelled = entity.IsCancelled,
                IsWorking   = entity.IsWorking,
                Domain      = entity.PatternValue,
                StartTime   = entity.StartDate,
                EndTime     = entity.EndDate
            };

            return(pattern);
        }