public void RemoveShip(Ship ship, bool removeEquip = true) { var infleet = ship.InFleet; if (infleet != null) { DispatcherHelper.UIDispatcher.Invoke(() => { infleet.Ships?.Remove(ship); infleet.UpdateStatus(); }); } if (removeEquip) { foreach (var slot in ship.Slots) { if (slot.HasItem) { Equipments.Remove(slot.Item); } } if (ship.SlotEx.HasItem) { Equipments.Remove(ship.SlotEx.Item); } } Ships.Remove(ship); UpdateCounts(); }
private void DeleteEquipment(object obj) { if (MessageBox.Show("Are you Sure You want to Delete this Record?", "Pinna Fitness", MessageBoxButton.YesNoCancel, MessageBoxImage.Warning) == MessageBoxResult.Yes) { try { SelectedEquipment.Enabled = false; var stat = _equipmentService.Disable(SelectedEquipment); if (stat == string.Empty) { Equipments.Remove(SelectedEquipment); } else { MessageBox.Show("Can't Delete, may be the data is already in use..." + Environment.NewLine + stat, "Can't Delete", MessageBoxButton.OK, MessageBoxImage.Error); } } catch (Exception ex) { MessageBox.Show("Can't Delete, may be the data is already in use..." + Environment.NewLine + ex.Message + Environment.NewLine + ex.InnerException, "Can't Delete", MessageBoxButton.OK, MessageBoxImage.Error); } } }
public bool RemoveEquipment(string id) { if (!Equipments.Any(x => x == id)) { return(false); } Equipments.Remove(id); return(true); }
public void RemoveShip(Ship ship) { ship.InFleet?.Ships.Remove(ship); ship.InFleet?.UpdateStatus(); foreach (var slot in ship.Slots) { if (slot.HasItem) { Equipments.Remove(slot.Item); } } if (ship.SlotEx.HasItem) { Equipments.Remove(ship.SlotEx.Item); } Ships.Remove(ship); UpdateCounts(); }
public void Remove(int id) { var item = Items.FirstOrDefault(i => i.Id == id); var equipment = Equipments.FirstOrDefault(e => e.Id == id); if (item == null && equipment == null) { return; } if (item != null) { Items.Remove(item); } else if (equipment != null) { Equipments.Remove(equipment); } }
private async void OnRemoveExecute() { var isReferenced = await _equipmentRepository.IsReferencedByExerciseAsync(SelectedEquipment.Id); if (isReferenced) { await MessageDialogService.ShowInfoDialogAsync($"{SelectedEquipment.Name} не може да бъде премахнато" + $", понеже се съдържа в поне едно упражнение."); return; } SelectedEquipment.PropertyChanged -= Wrapper_PropertyChanged; _equipmentRepository.Remove(SelectedEquipment.Model); Equipments.Remove(SelectedEquipment); SelectedEquipment = null; HasChanges = _equipmentRepository.HasChanges(); ((DelegateCommand)SaveCommand).RaiseCanExecuteChanged(); }
public override void RemoveReference(ModelCode referenceId, long globalId) { switch (referenceId) { case ModelCode.EQUIPMENT_EQUIPCONTAINER: if (Equipments.Contains(globalId)) { Equipments.Remove(globalId); } else { CommonTrace.WriteTrace(CommonTrace.TraceWarning, "Entity (GID = 0x{0:x16}) doesn't contain reference 0x{1:x16}.", this.GID, globalId); } break; default: base.RemoveReference(referenceId, globalId); break; } }
private async void deleteEquipment(object obj) { var content = obj as EquipmentViewModel; try { var result = await CoreMethods.DisplayAlert("Info", $"Are you sure you want to delete {content.Name}?", "Alright", "Cancel"); if (result) { var isDeleted = await _restServices.DeleteEquipment(content.Id); if (isDeleted) { Equipments.Remove(content); } } } catch (Exception) { throw; } }
public void RemoveEquip(Equipment equipment) { Equipments.Remove(equipment); }