public ViewModel(Firefly.Box.Data.Entity e, bool allowInsertUpdateDelete = false) : this() { From = e; if (allowInsertUpdateDelete) { AllowInsertUpdateDelete(); } }
internal bool IsReadOnly(HashSet <ColumnBase> denyUpdateOf, HashSet <ColumnBase> onlyAllowUpdateOf, HashSet <ColumnBase> ignoreUpdateOf, Firefly.Box.Data.Entity updatebleEntity) { return(denyUpdateOf.Contains(_col) || onlyAllowUpdateOf.Count > 0 && !onlyAllowUpdateOf.Contains(_col) || _col.DbReadOnly || ignoreUpdateOf.Contains(_col) || (_col.Entity != null && _col.Entity != updatebleEntity)); }
internal void UpdateDataBasedOnItem(DataItem item, HashSet <ColumnBase> denyUpdateOf, HashSet <ColumnBase> onlyAllowUpdateOf, ViewModelState state, Firefly.Box.Data.Entity updatebleEntity, HashSet <ColumnBase> ignoreUpdateOf, bool disableCannotBeUpdatedError) { if ((_col.Entity == null || _col.Entity == updatebleEntity) && !ignoreUpdateOf.Contains(_col)) { if (item.ContainsKey(_key)) { _setValueBasedOnDataItem(item[_key]); } if (!Comparer.Equal(_col.OriginalValue, _col.Value)) { if (IsReadOnly(denyUpdateOf, onlyAllowUpdateOf, ignoreUpdateOf, updatebleEntity)) { if (!disableCannotBeUpdatedError) { state.AddError(_col, "cannot be updated"); } else { _col.Value = _col.OriginalValue; _col.DbReadOnly = true; } } } } }