public void UpdateObjective(ObjectiveEditorViewModel viewModel, ObjectivePart objectivePart) { foreach (var objectiveResultPreset in objectivePart.ObjectiveResultPresets) { _objectiveResultPresetRepository.Delete(objectiveResultPreset); } objectivePart.ObjectiveResultPresets.Clear(); for (int i = 0; i < viewModel.ObjectiveResultPresets.Count; i++) { var objectiveResultPreset = viewModel.ObjectiveResultPresets[i]; var newPreset = new ObjectiveResultPresetRecord { DisplayName = objectiveResultPreset.DisplayName, Points = objectiveResultPreset.Points, Position = i, ObjectivePartRecord = objectivePart.Record, }; _objectiveResultPresetRepository.Create(newPreset); objectivePart.ObjectiveResultPresets.Add(newPreset); } var game = _gameService.Get(viewModel.GameId); objectivePart.Game = game.Record; }
protected override DriverResult Editor(ObjectivePart part, IUpdateModel updater, dynamic shapeHelper) { var viewModel = new ObjectiveEditorViewModel(); updater.TryUpdateModel(viewModel, Prefix, null, null); var game = _gameService.Value.Get(viewModel.GameId); part.Game = game != null ? game.Record : null; _objectiveService.Value.UpdateObjective(viewModel, part); return(Editor(part, shapeHelper)); }