void ObjectsItemEndEdit(IEditableObject sender) { RecursoPrecioViewModel UIObject = sender as RecursoPrecioViewModel; try { RecursoPrecioDataAccess.UpdateRecursoPrecio(UIObject.GetDataObject()); } catch (Exception ex) { log.Error(ex.StackTrace); } }
void ObjectsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Remove) { try { foreach (object item in e.OldItems) { RecursoPrecioViewModel UIObject = item as RecursoPrecioViewModel; RecursoPrecioDataAccess.DeleteRecursoPrecio(UIObject.GetDataObject()); } } catch (Exception ex) { log.Error(ex.StackTrace); } } }
public RecursoPrecioCollectionViewModel GetObjects() { RecursoPrecioCollectionViewModel UIObjects = new RecursoPrecioCollectionViewModel(); // List<RecursoPrecio> dataObjects = RecursoPrecioDataAccess.GetRecursoPrecio(); List <RecursoPrecio> dataObjects = RecursoPrecioDataAccess.GetRecursoPrecio(); foreach (RecursoPrecio dataObject in dataObjects) { UIObjects.Add(new RecursoPrecioViewModel(dataObject)); } UIObjects.ItemEndEdit += new ItemEndEditEventHandler(ObjectsItemEndEdit); UIObjects.CollectionChanged += new NotifyCollectionChangedEventHandler(ObjectsCollectionChanged); return(UIObjects); }