//public Task OnOrganizationChanged(string value) //{ // if (value != null) // Model.Organization = value; // return Task.CompletedTask; //} //public Task OnProcessNameChanged(string value) //{ // if (value != null) // Model.ProcessName = value; // return Task.CompletedTask; //} public async Task OnValidSubmit(EditContext context) { ShowProcessing(); var valid = context.Validate(); if (valid) { try { await Task.Delay(1 * 1000); // todo fix workaround valid = context.Validate(); if (valid && OperationTypeTicket == OperatioType.Create) { Model.Status = AdoModels.Status.Submitted; var added = await AdoProjectDataService.AddItemAsync(Model); if (added != null) { Success = true; Model = added; } } else if (valid && OperationTypeTicket == OperatioType.Edit) { var updated = await AdoProjectDataService.UpdateItemAsync(Model); if (updated != null) { await CsroDialogService.ShowMessage("Success", $"Update Finished", "Refresh"); await Load(); } else { var ok = await CsroDialogService.ShowWarning("Update Error", $"Conflic Detected, Please refresh and try again", "Refresh"); if (ok) { await Load(); } } } StateHasChanged(); } catch (Exception ex) { Logger.LogErrorCsro(ex); await CsroDialogService.ShowError("Error", $"Detail error: {ex.Message}"); } } HideLoading(); }
public async Task OnValidSubmit(EditContext context) { var valid = context.Validate(); if (valid) { try { ShowLoading(); if (OperationTypeTicket == OperatioType.Create) { var added = await TicketDataService.AddItemAsync(Model); if (added != null) { await CsroDialogService.ShowMessage("Success", $"Ticket created."); GoBack(); } } else if (OperationTypeTicket == OperatioType.Edit) { var updated = await TicketDataService.UpdateItemAsync(Model); if (updated != null) { await Load(); await CsroDialogService.ShowMessage("Success", $"Ticket updated."); } else { var ok = await CsroDialogService.ShowWarning("Update Error", $"Conflic Detected, Please refresh and try again", "Refresh"); if (ok) { await Load(); } } } StateHasChanged(); } catch (Exception ex) { Logger.LogErrorCsro(ex); await CsroDialogService.ShowError("Error", $"Detail error: {ex.Message}"); } HideLoading(); } }
public async Task OnValidSubmit(EditContext context) { var valid = context.Validate(); if (valid) { try { if (OperationTypeTicket == OperatioType.Create) { ShowLoading("Creating request"); var added = await VmTicketDataService.AddItemAsync(Model); //var added = await VmTicketDataService.CreateVmTicketAndWaitForConfirmation(Model); if (added != null) { Success = true; Model = added; ShowLoading("Success, please wait"); StateHasChanged(); await Task.Delay(3 * 1000); HideLoading(); NavigationManager.NavigateTo($"vm/restart/view/{Model.Id}"); } } else if (OperationTypeTicket == OperatioType.Edit) { ShowLoading("Updating request"); var updated = await VmTicketDataService.UpdateItemAsync(Model); if (updated != null) { Success = true; //throw new Exception("Fake Test exception"); } else { var ok = await CsroDialogService.ShowWarning("Update Error", $"Conflic Detected, Please refresh and try again", "Refresh"); if (ok) { await LoadAsync(); } } } StateHasChanged(); } catch (Exception ex) { Logger.LogErrorCsro(ex); await CsroDialogService.ShowError("Error", $"Detail error: {ex.Message}"); } finally { HideLoading(); } } }