void ObjectsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Remove) { try { foreach (object item in e.OldItems) { AreaViewModel UIObject = item as AreaViewModel; AreasDataAccess.DeleteObject(UIObject.GetDataObject()); } } catch (Exception ex) { log.Error(ex.StackTrace); } } }
void ObjectsItemEndEdit(IEditableObject sender) { AreaViewModel UIObject = sender as AreaViewModel; try { if (UIObject.Name != null) { int id = AreasDataAccess.UpdateObject(UIObject.GetDataObject()); if (id != -1) { UIObject.Id = id; } } } catch { UIObjects.Remove(UIObject); RadWindow.Alert(new DialogParameters { Content = MessageUtil.FormatMessage("ERROR.DuplicatedEntryName", UIObject.Name) }); } }