private bool Save(ICollection <PmConfiguratorData> changes) { if (!HasChanges(changes)) { return(true); } try { WaitStart(); var pm2Operations = new List <PM2Operation>(); var pmConfigs = new List <PMConfig>(); GetPmEntities(changes, null, ref pm2Operations, ref pmConfigs); var deletePm2Operations = new List <PM2Operation>(); var deletePmConfigs = new List <PMConfig>(); var dataForDelete = DataForDelete.Select(p => p.Value).ToArray(); GetPmEntities(dataForDelete, (item => item != null && !string.IsNullOrEmpty(item.PmCode)), ref deletePm2Operations, ref deletePmConfigs); List <string> errors; using (var manager = IoC.Instance.Resolve <IBPProcessManager>()) { errors = manager.SavePmConfiguratorData(pm2Operations, pmConfigs, deletePm2Operations, deletePmConfigs); } if (errors != null && errors.Count > 0) { var message = string.Format(Properties.Resources.ValidationError, Environment.NewLine, string.Join(Environment.NewLine, errors.Distinct())); var vs = GetViewService(); vs.ShowDialog(StringResources.Error , message , MessageBoxButton.OK , MessageBoxImage.Error , MessageBoxResult.Yes); return(false); } AcceptChanges(ItemsSource); IsDeleted.Clear(); DataForDelete.Clear(); return(true); } catch (Exception ex) { if (!ExceptionHandler(ex, ExceptionResources.ItemCantSave)) { throw; } return(false); } finally { WaitStop(); } }
private async void GetData() { ItemsSource = null; try { WaitStart(); IsDeleted.Clear(); DataForDelete.Clear(); var data = await GetDataAsync(); if (data == null) { return; } var itemsSource = new ObservableCollection <PmConfiguratorData>(data); AcceptChanges(itemsSource); ItemsSource = itemsSource; } catch (Exception ex) { if (!ExceptionHandler(ex, ExceptionResources.ItemCantRefresh)) { throw; } } finally { WaitStop(); } }