private void OnComponentAdded() { if (SelectedComponent != null && SelectedComponent.ComponentName != null) { if (EquipmentComponents.Count(ec => ec.ComponentName == SelectedComponent.ComponentName) < 1) { EquipmentComponents.Add(new EquipmentComponent() { ComponentID = SelectedComponent.ComponentId, ComponentName = SelectedComponent.ComponentName, EquipmentID = SelectedEquipment.EquipmentId }); _equipmentRepository.UpdateComponents(SelectedComponent, SelectedEquipment.EquipmentId); //add to context //await _equipmentRepository.SaveAsync(); } else { MessageBox.Show("The component name already exists for this equipment.", "Message", MessageBoxButton.OK, MessageBoxImage.Information); } } else { MessageBox.Show("Please select a component and specify a component name before adding.", "Message", MessageBoxButton.OK, MessageBoxImage.Information); } }
private void OnComponentRemoved() { if (SelectedListComponentIndex != null) { _equipmentRepository.RemoveEquipmentComponent(EquipmentComponents[(int)SelectedListComponentIndex]); //remove from context EquipmentComponents.RemoveAt((int)_selectListComponentIndex); SelectedListComponentIndex = null; } else { MessageBox.Show("Please select a component in the list to remove.", "Message", MessageBoxButton.OK, MessageBoxImage.Information); } }
private async void LoadComponentForEquipment(int equipmentId) { var equipmentComponents = _equipmentRepository.GetEquipmentComponents(SelectedEquipment.EquipmentId); EquipmentComponents.Clear(); foreach (var item in equipmentComponents) { EquipmentComponents.Add(item); } /*var components = await _componentDataService.GetComponentsByEquipmentIdAsync(equipmentId); * ComponentsForEquipment.Clear(); * foreach (var item in components) * { * ComponentsForEquipment.Add(item); * }*/ }