private async Task Load() { try { ShowLoading(); //var mefull = await GraphClientService.GetCurrentGraphUserModel(); //var upnFull = await GraphClientService.GetUserByUpnEmailGraphUserModel("*****@*****.**"); ////var email = await GraphClientService.GetUserByUpnEmail("*****@*****.**"); //var me = await GraphClientService.GetCurrentGraphUser(); //var upn = await GraphClientService.GetUserByUpnEmail("*****@*****.**"); if (OperationTypeTicket != OperatioType.Create) { Model.Id = int.Parse(TicketId); var server = await TicketDataService.GetItemByIdAsync(Model.Id); if (server != null) { Model = server; } } } 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 DeleteTicketAsync(Ticket ticket) { throw new Exception("Fake!!! Exception in DeleteTicketAsync"); var ok = await CsroDialogService.ShowDialog("Delete Ticket", $"Do you really want to delete these record Id: {ticket.Id}?", "Delete"); if (ok) { var res = await TicketDataService.DeleteItemAsync(ticket.Id); if (res) { Tickets.Remove(ticket); } } }
protected async override Task OnInitializedAsync() { //throw new Exception("test excpetion"); try { ShowLoading(); Tickets.Clear(); Tickets = await TicketDataService.GetItemsAsync(); } catch (Exception ex) { Logger.LogErrorCsro(ex); await CsroDialogService.ShowError("Error", ex?.Message); } HideLoading(); }