public LoadoutWindow(bool isManageMode, string selectedLoadoutName, IEnumerable <AbilityViewModel> abilities) { InitializeComponent(); loadoutSelectorViewModel = new LoadoutSelectorViewModel(isManageMode, OnEnd, abilities); if (selectedLoadoutName == null) { loadoutSelectorViewModel.SelectedLoadout = null; } else { currentLoadout = loadoutSelectorViewModel.Loadouts.FirstOrDefault(x => x.Name == selectedLoadoutName); if (currentLoadout != null) { CurrentLoadoutName = currentLoadout.Name; loadoutSelectorViewModel.SelectedLoadout = currentLoadout; } else { CurrentLoadoutName = null; loadoutSelectorViewModel.SelectedLoadout = null; } } InputBindings.Add(new KeyBinding(loadoutSelectorViewModel.AcceptCommand, new KeyGesture(Key.Enter, ModifierKeys.None))); InputBindings.Add(new KeyBinding(new AnonymousCommand(OnCancel), new KeyGesture(Key.Escape, ModifierKeys.None))); DataContext = loadoutSelectorViewModel; }
public IActionResult PostLoadout(LoadoutViewModel viewModel) { if (ModelState.IsValid) { var dbCharacter = _repository.GetCharacter(viewModel.CharacterId); if (dbCharacter == null) { return(NotFound()); } if (!IsCharacterEditAuthorised(dbCharacter)) { return(Unauthorized()); } _repository.UpdateLoadout(viewModel.Loadout); return(Ok()); } List <ModelError> allErrors = ModelState.Values.SelectMany(v => v.Errors).ToList(); return(BadRequest(allErrors)); }
private void LoadLoadoutFromViewModel(LoadoutViewModel loadoutViewModel) { for (int i = 0; i < rootViewModel.InParameters.Slots.Length; i++) { if (i < loadoutViewModel.WeaponSlots.Length) { rootViewModel.InParameters.Slots[i].Value = loadoutViewModel.WeaponSlots[i]; } else { rootViewModel.InParameters.Slots[i].Value = 0; } } foreach (AbilityViewModel ability in rootViewModel.SelectedAbilities) { ability.IsChecked = loadoutViewModel.Abilities.Any(a => a.SkillId == ability.SkillId && a.Level == ability.Level); } }