public async Task ActionBegin(ActionEventArgs <TiposNoConf> args) { if (args.RequestType == Syncfusion.Blazor.Grids.Action.Save) { HttpResponseMessage response; bool found = tiposnoconfs.Any(p => p.Cg_TipoNc == args.Data.Cg_TipoNc); TiposNoConf ur = new TiposNoConf(); if (!found) { args.Data.CG_CIA = 1; args.Data.USUARIO = "User"; response = await Http.PostAsJsonAsync("api/TiposNoConf", args.Data); args.Data.Cg_TipoNc = tiposnoconfs.Max(s => s.Cg_TipoNc) + 1; } else { response = await Http.PutAsJsonAsync($"api/TiposNoConf/{args.Data.Cg_TipoNc}", args.Data); } if (response.StatusCode == System.Net.HttpStatusCode.Created) { } } if (args.RequestType == Syncfusion.Blazor.Grids.Action.Delete) { await EliminarTiposNoConf(args); } }
public async Task ClickHandler(Syncfusion.Blazor.Navigations.ClickEventArgs args) { if (args.Item.Text == "Copy") { if (this.Grid.SelectedRecords.Count > 0) { foreach (TiposNoConf selectedRecord in this.Grid.SelectedRecords) { bool isConfirmed = await JsRuntime.InvokeAsync <bool>("confirm", "Seguro de que desea copiar Tipo no Conforme?"); if (isConfirmed) { TiposNoConf Nuevo = new TiposNoConf(); Nuevo.Des_TipoNc = selectedRecord.Des_TipoNc; Nuevo.CG_CIA = 1; Nuevo.USUARIO = "User"; var response = await Http.PostAsJsonAsync("api/TiposNoConf", Nuevo); Nuevo.Cg_TipoNc = tiposnoconfs.Max(s => s.Cg_TipoNc) + 1; if (response.StatusCode == System.Net.HttpStatusCode.Created) { Grid.Refresh(); var TiposNoConf = await response.Content.ReadFromJsonAsync <TiposNoConf>(); await InvokeAsync(StateHasChanged); Nuevo.Cg_TipoNc = TiposNoConf.Cg_TipoNc; tiposnoconfs.Add(Nuevo); var itemsJson = JsonSerializer.Serialize(TiposNoConf); Console.WriteLine(itemsJson); //toastService.ShowToast($"Registrado Correctemente.Vale {StockGuardado.VALE}", TipoAlerta.Success); tiposnoconfs.OrderByDescending(p => p.Cg_TipoNc); } } } } Refresh(); } if (args.Item.Text == "Excel Export") { await this.Grid.ExcelExport(); } }