private void RemoveEquipment(EquipmentViewModel equipmentViewModel) { bool?result = _dialogService.ShowConfirmationDialog("Remove Item", "Are you sure you want to remove " + equipmentViewModel.Name + "?", "Yes", "No", null); if (result == true) { _bagModel.Equipment.Remove(equipmentViewModel.EquipmentModel); _equipment.Remove(equipmentViewModel); OnPropertyChanged(nameof(Equipment)); OnPropertyChanged(nameof(ShowEquipmentHeader)); UpdateTotalWeight(); } }
/// <summary> /// Creates an instance of <see cref="BagViewModel"/> /// </summary> public BagViewModel(BagModel bagModel) : base() { _bagModel = bagModel; foreach (EquipmentModel equipmentModel in bagModel.Equipment.OrderBy(x => x.Name)) { EquipmentViewModel equipmentViewModel = new EquipmentViewModel(equipmentModel); equipmentViewModel.PropertyChanged += EquipmentViewModel_PropertyChanged; _equipment.Add(equipmentViewModel); } UpdateTotalWeight(); _showAddEquipmentDialogCommand = new RelayCommand(obj => true, obj => ShowAddEquipmentDialog()); _showAddPackDialogCommand = new RelayCommand(obj => true, obj => ShowAddPackDialog()); _showEditEquipmentDialogCommand = new RelayCommand(obj => true, obj => ShowEditEquipmentDialog((EquipmentViewModel)obj)); _removeEquipmentCommand = new RelayCommand(obj => true, obj => RemoveEquipment((EquipmentViewModel)obj)); _showUpdateMoneyDialogCommand = new RelayCommand(obj => true, obj => ShowUpdateMoneyDialog((Currency)obj)); }
private void ShowAddEquipmentDialog() { EquipmentModel equipmentModel = _dialogService.ShowCreateEquipmentDialog("Add Item", new EquipmentModel()); if (equipmentModel != null) { EquipmentViewModel equipmentViewModel = new EquipmentViewModel(equipmentModel); equipmentViewModel.PropertyChanged += EquipmentViewModel_PropertyChanged; _equipment.Add(equipmentViewModel); _bagModel.Equipment.Add(equipmentModel); _equipment = new ObservableCollection <EquipmentViewModel>(_equipment.OrderBy(x => x.Name)); OnPropertyChanged(nameof(Equipment)); OnPropertyChanged(nameof(ShowEquipmentHeader)); UpdateTotalWeight(); } }
private void ShowEditEquipmentDialog(EquipmentViewModel equipmentViewModel) { EquipmentModel equipmentModel = _dialogService.ShowCreateEquipmentDialog($"Edit {equipmentViewModel.Name}", equipmentViewModel.EquipmentModel); if (equipmentModel != null) { _equipment.Remove(equipmentViewModel); _bagModel.Equipment.Remove(equipmentViewModel.EquipmentModel); EquipmentViewModel newEquipmentViewModel = new EquipmentViewModel(equipmentModel); newEquipmentViewModel.PropertyChanged += EquipmentViewModel_PropertyChanged; _equipment.Add(newEquipmentViewModel); _bagModel.Equipment.Add(equipmentModel); _equipment = new ObservableCollection <EquipmentViewModel>(_equipment.OrderBy(x => x.Name)); OnPropertyChanged(nameof(Equipment)); OnPropertyChanged(nameof(ShowEquipmentHeader)); UpdateTotalWeight(); } }