void CancelChild() { _child = new CategoryDescriptorModel(); if (Readonly) { childrenEditingEnabled = false; } StateHasChanged(); }
void CancelParent() { ParentCategory = new CategoryDescriptorModel { Code = _originalParent.Code, Id = _originalParent.Id, Name = _originalParent.Name }; if (Readonly) { parentEditingEnabled = false; } StateHasChanged(); }
async Task RemoveChild(CategoryDescriptorModel child) { try { await Client.DeleteCategoryChild(_CategoryId, child.Id); category.Children.Remove(child); } catch { errorRaised = true; } finally { StateHasChanged(); } }
async Task SetParent(CategoryDescriptorModel parent) { try { await Client.AddCategoryParent(_CategoryId, parent.Id); category.Parent = parent; } catch { errorRaised = true; } finally { StateHasChanged(); } }
async Task RemoveParent(CategoryDescriptorModel parent) { try { await Client.DeleteCategoryParent(_CategoryId, parent.Id); category.Parent = new CategoryDescriptorModel(); } catch { errorRaised = true; } finally { StateHasChanged(); } }
protected override Task OnInitializedAsync() { parentContext = new EditContext(ParentCategory); childrenContext = new EditContext(Children); parentEditingEnabled = !Readonly; childrenEditingEnabled = !Readonly; _parentIsEmpty = ParentCategory.IsEmpty; _originalParent = new CategoryDescriptorModel { Code = ParentCategory.Code, Id = ParentCategory.Id, Name = ParentCategory.Name }; return(base.OnInitializedAsync()); }
async Task RemoveChild(CategoryDescriptorModel child) => await OnChildRemoved.InvokeAsync(child);
async Task AddChild() { await OnChildAdded.InvokeAsync(_child); _child = new CategoryDescriptorModel(); }