public Task <bool> SaveItem(IPropertyValueAccessor 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; } }
public ImutableGridRendererContext( IEntityType gridEntityConfiguration, List <PropertyInfo> itemProperties, IPropertyValueAccessor propertyValueAccessor ) { valueFormatters = new Dictionary <string, ValueFormatter>(); gridItemCollectionProperties = new List <PropertyInfo>(); GridEntityConfiguration = gridEntityConfiguration ?? throw new ArgumentNullException(nameof(gridEntityConfiguration)); GridItemProperties = itemProperties ?? throw new ArgumentNullException(nameof(itemProperties)); GetPropertyValueAccessor = propertyValueAccessor ?? throw new ArgumentNullException(nameof(propertyValueAccessor)); InitializeGridProperties(); }
public ImutableGridRendererContext( IEntityType gridEntityConfiguration, IPropertyValueAccessor propertyValueAccessor, ICurrentUserPermission currentUserPermission) { valueFormatters = new Dictionary <string, ValueFormatter>(); specialColumnValues = new Dictionary <string, RenderFragmentAdapter>(); gridItemCollectionProperties = new List <PropertyInfo>(); GridEntityConfiguration = gridEntityConfiguration ?? throw new ArgumentNullException(nameof(gridEntityConfiguration)); GetPropertyValueAccessor = propertyValueAccessor ?? throw new ArgumentNullException(nameof(propertyValueAccessor)); this.currentUserPermission = currentUserPermission ?? throw new ArgumentNullException(nameof(currentUserPermission)); PermissionContext = new PermissionContext(currentUserPermission, gridEntityConfiguration); }
public void AddPropertyAccessor(Type type, IPropertyValueAccessor propertyValueAccessor) { if (type is null) { throw new ArgumentNullException(nameof(type)); } if (propertyValueAccessor is null) { throw new ArgumentNullException(nameof(propertyValueAccessor)); } if (propertyAccessors.ContainsKey(type)) { return; } propertyAccessors.Add(type, propertyValueAccessor); }
public GridRendererContext( ImutableGridRendererContext imutableGridRendererContext, RenderTreeBuilder renderTreeBuilder, ITableDataSet tableDataSet) { if (imutableGridRendererContext is null) { throw new ArgumentNullException(nameof(imutableGridRendererContext)); } GridItemProperties = imutableGridRendererContext.GridItemProperties; CssClasses = imutableGridRendererContext.CssClasses; GridConfiguration = new GridAnotations(imutableGridRendererContext.GridEntityConfiguration); TableDataSet = tableDataSet ?? throw new ArgumentNullException(nameof(tableDataSet)); this.gridEntityConfiguration = imutableGridRendererContext.GridEntityConfiguration; this.propertyValueAccessor = imutableGridRendererContext.GetPropertyValueAccessor; this.valueFormatters = imutableGridRendererContext.ValueFormatters; this.renderTreeBuilder = renderTreeBuilder ?? throw new ArgumentNullException(nameof(renderTreeBuilder)); this.firstColumnName = GridItemProperties.First().Name; }
public async Task <bool> SaveItem(IPropertyValueAccessor 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); }
public Task <bool> SaveItem(IPropertyValueAccessor propertyValueAccessor) => tableDataSet.SaveItem(propertyValueAccessor);