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 CreateItemRendererContext(ICreateItemFormViewModel <TItem> createItemFormViewModel, ITypePropertyAccessorCache typePropertyAccessorCache)
        {
            this.typePropertyAccessor = typePropertyAccessorCache?.GetPropertyAccesor(typeof(TItem))
                                        ?? throw new ArgumentNullException(nameof(typePropertyAccessorCache));

            this.ViewModel = createItemFormViewModel ?? throw new ArgumentNullException(nameof(createItemFormViewModel));
        }
        public CreateItemRendererContext(
            ICreateItemFormViewModel <TModel> createItemFormViewModel,
            ITypePropertyAccessorCache typePropertyAccessorCache,
            CreateFormCssClasses createFormCssClasses)
        {
            this.typePropertyAccessor = typePropertyAccessorCache?.GetPropertyAccesor(typeof(TModel))
                                        ?? throw new ArgumentNullException(nameof(typePropertyAccessorCache));

            this.ViewModel            = createItemFormViewModel ?? throw new ArgumentNullException(nameof(createItemFormViewModel));
            this.CreateFormCssClasses = createFormCssClasses ?? new DefaultCreateFormCssClasses();
        }
Ejemplo n.º 4
0
        public CreateItemRendererContext(
            ICreateItemFormViewModel <TModel> createItemFormViewModel,
            ITypePropertyAccessorCache typePropertyAccessorCache,
            CreateFormCssClasses createFormCssClasses,
            IEntityType entityConfiguration)
        {
            _typePropertyAccessor = typePropertyAccessorCache?.GetPropertyAccesor(typeof(TModel))
                                    ?? throw new ArgumentNullException(nameof(typePropertyAccessorCache));

            ViewModel         = createItemFormViewModel ?? throw new ArgumentNullException(nameof(createItemFormViewModel));
            _annotationLookup = entityConfiguration.GetProperties()
                                .ToDictionary(p => p.Name, p => (INewItemAnnotations) new NewItemAnnotations(p));
            CreateFormCssClasses = createFormCssClasses ?? new DefaultCreateFormCssClasses();
        }
        public ImutableGridRendererContext(
            IEntityType gridEntityConfiguration,
            ITypePropertyAccessor 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 ImutableGridRendererContext(
            IEntityType gridEntityConfiguration,
            ITypePropertyAccessor propertyValueAccessor,
            ICurrentUserPermission currentUserPermission)
        {
            valueFormatters     = new Dictionary <string, IValueFormatter>();
            specialColumnValues = new Dictionary <string, IRenderFragmentAdapter>();

            GridEntityConfiguration  = gridEntityConfiguration ?? throw new ArgumentNullException(nameof(gridEntityConfiguration));
            GetPropertyValueAccessor = propertyValueAccessor ?? throw new ArgumentNullException(nameof(propertyValueAccessor));

            PermissionContext = new PermissionContext(currentUserPermission, gridEntityConfiguration);
            GridConfiguration = new GridAnotations(gridEntityConfiguration);
            CssClasses        = GridConfiguration.CssClasses;
        }
Ejemplo n.º 7
0
        public void AddPropertyAccessor(Type type, ITypePropertyAccessor 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);
        }
Ejemplo n.º 8
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);
        }
 public Task <bool> SaveItem(ITypePropertyAccessor propertyValueAccessor)
 => tableDataSet.SaveItem(propertyValueAccessor);