Ejemplo n.º 1
0
        public Task <bool> SaveItem(ITypePropertyAccessor propertyValueAccessor)
        {
            try
            {
                foreach (var newValue in RowEditOptions.UpdatedValues)
                {
                    propertyValueAccessor.SetValue(RowEditOptions.ItemInEditMode, newValue.Key, newValue.Value);
                }

                GridViewEvents.SaveOperationFinished?.Invoke(new SaveResultArgs {
                    ItemSucessfullySaved = true, Item = RowEditOptions.ItemInEditMode
                });

                return(Task.FromResult(true));
            }
            catch (Exception)
            {
                GridViewEvents.SaveOperationFinished?.Invoke(new SaveResultArgs {
                    ItemSucessfullySaved = false
                });
                return(Task.FromResult(false));
            }
            finally
            {
                RowEditOptions.ItemInEditMode = EmptyDataSetItem.Instance;
            }
        }
Ejemplo n.º 2
0
        public async Task <bool> SaveItem(ITypePropertyAccessor propertyValueAccessor)
        {
            try
            {
                foreach (var newValue in RowEditOptions.UpdatedValues)
                {
                    propertyValueAccessor.SetValue(RowEditOptions.ItemInEditMode, newValue.Key, newValue.Value);
                }
            }
            catch (Exception)
            {
                GridViewEvents.SaveOperationFinished?.Invoke(new SaveResultArgs {
                    ItemSucessfullySaved = false
                });
                RowEditOptions.ItemInEditMode = EmptyDataSetItem.Instance;

                return(false);
            }

            var typedItem  = (TItem)RowEditOptions.ItemInEditMode;
            var saveResult = await lazyDataSetItemSaver.SaveItem(typedItem, LazyLoadingOptions);

            if (saveResult != null)
            {
                var itemIndex = Items.IndexOf(typedItem);
                if (itemIndex > -1)
                {
                    Items[itemIndex] = saveResult;
                }

                GridViewEvents.SaveOperationFinished?.Invoke(new SaveResultArgs {
                    ItemSucessfullySaved = true, Item = saveResult
                });
            }

            RowEditOptions.ItemInEditMode = EmptyDataSetItem.Instance;

            return(saveResult != null ? true : false);
        }
Ejemplo n.º 3
0
 public void SetActualItemColumnValue(string columnName, object value)
 => _typePropertyAccessor.SetValue(ViewModel.Model, columnName, value);