public async Task DeleteTicketAsync(VmTicket ticket) { var ok = await CsroDialogService.ShowDialog("Delete Vm Ticket", $"Do you really want to delete these record Id: {ticket.Id}?", "Delete"); if (ok) { var res = await VmTicketDataService.DeleteItemAsync(ticket.Id); if (res) { Tickets.Remove(ticket); } } }
protected async override Task OnInitializedAsync() { try { ShowLoading(); Tickets = null; Tickets = await VmTicketDataService.GetItemsAsync(); } catch (Exception ex) { Logger.LogErrorCsro(ex); } 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(); } } }
public async override Task LoadAsync() { try { if (OperationTypeTicket != OperatioType.Create) { ShowLoading(); Model.Id = int.Parse(TicketId); var server = await VmTicketDataService.GetItemByIdAsync(Model.Id); await LoadRg(server?.SubcriptionId); if (server != null) { Model = server; if (OperationTypeTicket == OperatioType.View) { #region Verify old Code //if (Model.VmState == "Restart Started" || !string.Equals(Model.VmState, "VM running")) //{ // //need to create delay to update vm state after restart // LoadingMessage = $"Current state: {Model.VmState}"; // StateHasChanged(); // var running = await VmTicketDataService.VerifyRestartStatusCallback(Model, (status)=> // { // LoadingMessage = $"Current state: {status}"; // StateHasChanged(); // }).ConfigureAwait(false); // if (running) // { // Model = await VmTicketDataService.GetItemByIdAsync(Model.Id); // } //} #endregion } } } else { ShowLoading(); Subscripions = await SubcriptionDataService.GetSubcriptions(); Subscripions = Subscripions ?? new List <IdName>(); #if DEBUG if (Model.ExternalTicket == null) { Model.ExternalTicket = "Inc132666FakeTicket"; } if (Subscripions?.Count == 1) { var id = Subscripions.First().Id; Subscripions.Add(new IdName(id, $"fake-sub-prod")); Subscripions.Add(new IdName(id, $"fake-sub-uat")); Subscripions.Add(new IdName(id, $"fake-sub-dev")); Subscripions.Add(new IdName(id, $"fake-sub-appdev")); Subscripions.Add(new IdName(id, $"fake-sub-test")); } #endif } } catch (Exception ex) { Logger.LogErrorCsro(ex); await CsroDialogService.ShowError("Error", $"Detail error: {ex.Message}"); } finally { HideLoading(); } }