protected override async Task OnInitializedAsync() { try { WorkstationService = ScopedServices.GetRequiredService <IWorkstationService>(); RemoteWorkstationConnectionsService = ScopedServices.GetRequiredService <IRemoteWorkstationConnectionsService>(); Workstation = await WorkstationService.GetWorkstationByIdAsync(WorkstationId); if (Workstation == null) { throw new Exception("Workstation not found."); } EntityBeingEdited = MemoryCache.TryGetValue(Workstation.Id, out object _); if (!EntityBeingEdited) { MemoryCache.Set(Workstation.Id, Workstation); } SetInitialized(); } catch (Exception ex) { Logger.LogError(ex.Message); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); await ModalDialogCancel(); } }
private async Task LoadWorkstationAsync() { Workstation = await WorkstationService.GetWorkstationByIdAsync(WorkstationId); if (Workstation == null) { throw new Exception("Workstation not found."); } }
protected override async Task OnInitializedAsync() { try { WorkstationService = ScopedServices.GetRequiredService <IWorkstationService>(); OrgStructureService = ScopedServices.GetRequiredService <IOrgStructureService>(); RemoteWorkstationConnectionsService = ScopedServices.GetRequiredService <IRemoteWorkstationConnectionsService>(); Workstation = await WorkstationService.GetWorkstationByIdAsync(WorkstationId); if (Workstation == null) { throw new Exception("Workstation not found."); } ModalDialogService.OnCancel += OnCancel; EntityBeingEdited = MemoryCache.TryGetValue(Workstation.Id, out object _); if (!EntityBeingEdited) { MemoryCache.Set(Workstation.Id, Workstation); } Companies = await OrgStructureService.GetCompaniesAsync(); if (Workstation.DepartmentId == null) { Departments = new List <Department>(); } else { Departments = await OrgStructureService.GetDepartmentsByCompanyIdAsync(Workstation.Department.CompanyId); } SetInitialized(); } catch (Exception ex) { Logger.LogError(ex.Message); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); await ModalDialogService.CancelAsync(); } }