private async void OnAddCustomItemExecute() { var dialogResult = await _messageDialogService.ShowInputMessageAsync(this, "Nowe pole zdefiniowane...", "Podaj nazwę nowego pola:"); if (!String.IsNullOrWhiteSpace(dialogResult)) { var wrappedCustomItem = new CustomItemWrapper(new CustomItem() { HardwareTypeId = SelectedHardwareType.Model.Id }); wrappedCustomItem.PropertyChanged += WrappedCustomItem_PropertyChanged; _customItemRepository.Add(wrappedCustomItem.Model); CustomItems.Add(wrappedCustomItem); wrappedCustomItem.Key = dialogResult; } }
private async Task LoadCustomItems() { foreach (var wrappedItem in CustomItems) { wrappedItem.PropertyChanged -= WrappedCustomItem_PropertyChanged; } CustomItems.Clear(); var customItems = await _customItemRepository.GetCustomItemsByHardwareTypeAsync(SelectedHardwareType.Id); foreach (var item in customItems) { var wrappedModel = new CustomItemWrapper(item); wrappedModel.PropertyChanged += WrappedCustomItem_PropertyChanged; if (CustomItems.Contains(wrappedModel)) { continue; } CustomItems.Add(wrappedModel); } }