protected async Task SubmitAsync() { if (!string.IsNullOrEmpty(Comment.Content) && Comment.Content != PreviousComment) { if (Id == null) { Comment.PostId = PostId; var contentActivity = new ContentActivity() { Node = Comment, Message = $"Added a new forum comment: {Comment.Snippet}" }; await NodeService.AddAsync(contentActivity); } else { var contentActivity = new ContentActivity() { Node = Comment, Message = $"Updated a new forum comment: {Comment.Snippet}" }; await NodeService.UpdateAsync(contentActivity); } await OnSave.InvokeAsync(Comment); PreviousComment = Comment.Content; Comment.Content = string.Empty; } }
protected async Task Save() { if (OnSave.HasDelegate) { IsSaving = true; await OnSave.InvokeAsync(EditingItem); } Editing(default);
protected async Task SubmitAsync() { if (string.IsNullOrEmpty(Id)) { Post.TopicId = TopicId; var contentActivity = new ContentActivity() { Node = Post, Message = $"Added a new forum post: {Post.Snippet}" }; await NodeService.AddAsync(contentActivity); } else { var contentActivity = new ContentActivity() { Node = Post, Message = $"Updated a forum post: {Post.Snippet}" }; await NodeService.UpdateAsync(contentActivity); } await OnSave.InvokeAsync(Post); }
private async Task SaveDataAsync(SaveAction saveAction) { if (DataType == null) { if (DataSource == null) { throw new BlazuiException(2, "DataType 或 DataSource 必须设置一个"); } DataType = DataSource.GetType().GetGenericArguments()[0]; } var row = Activator.CreateInstance(DataType); foreach (var header in Headers) { if ((!header.IsEditable && header.EditorRenderConfig == null) || (saveAction != SaveAction.Create && !CanEdit(header))) { if (header.Property != null && (header.Property.Name.Contains("Id") || header.Property.Name.Contains("Key")) && saveAction != SaveAction.Create) { header.Property.SetValue(row, header.Property.GetValue(header.RawValue)); } Clear(header); continue; } if (saveAction != SaveAction.Delete) { object cell = Convert.ChangeType(header.EditorRenderConfig.EditingValue, header.Property.PropertyType); if (header.EditorRenderConfig.IsRequired && cell == null) { Toast(header.EditorRenderConfig.RequiredMessage); editingTaskCompletionSource?.TrySetResult(-1); return; } header.Property.SetValue(row, cell); } Clear(header); } var tableSaveArg = new TableSaveEventArgs() { Action = saveAction, Data = row, Table = this, }; if (!OnSave.HasDelegate) { if (DataType == typeof(KeyValueModel)) { OnSave = EventCallback.Factory.Create <TableSaveEventArgs>(this, TableRender.DefaultSaverAsync); } else if (!string.IsNullOrWhiteSpace(Key)) { OnSave = EventCallback.Factory.Create <TableSaveEventArgs>(this, TableRender.DefaultSaverAsync); } else { Toast("OnSave 事件没有注册或数据源类型不是 KeyValueModel 或没指定 Key"); editingTaskCompletionSource?.TrySetResult(-1); return; } } tableSaveArg.Key = Key; tableSaveArg.DataType = DataType; if (editingTaskCompletionSource != null) { await OnSave.InvokeAsync(tableSaveArg); if (tableSaveArg.Cancel) { editingTaskCompletionSource.TrySetResult(-1); return; } editingRow = null; dataSourceUpdated = true; await RefreshDataSourceAsync(false); editingTaskCompletionSource.TrySetResult(0); SyncFieldValue(); } else { if (OnSave.HasDelegate) { await OnSave.InvokeAsync(tableSaveArg); if (tableSaveArg.Cancel) { editingTaskCompletionSource?.TrySetResult(-1); return; } editingRow = null; dataSourceUpdated = true; await RefreshDataSourceAsync(false); editingTaskCompletionSource?.TrySetResult(0); SyncFieldValue(); return; } editingTaskCompletionSource?.TrySetResult(-1); } }
public void HandleSave(TItem item) { OnSave.InvokeAsync(item); IsOpen = false; }
protected Task Save() => OnSave.InvokeAsync(TodoItem);
public async Task SaveAsync() { await OnSave.InvokeAsync(Category); }
Task Save() { return(OnSave.InvokeAsync(Agent)); }
protected async Task Save() { await JsRuntime.InvokeVoidAsync("laterlist.collapse", $"#{CollapseCardId}", "hide"); await OnSave.InvokeAsync(InternalTodoList); }