コード例 #1
0
ファイル: Screen.razor.cs プロジェクト: claunia/marechai
        async Task ConfirmAddResolution()
        {
            if (_addingResolutionId is null ||
                _addingResolutionId <= 0)
            {
                CancelAddResolution();

                return;
            }

            _savingResolution = true;

            // Yield thread to let UI to update
            await Task.Yield();

            await ResolutionsByScreenService.CreateAsync(_addingResolutionId.Value, Id,
                                                         (await UserManager.GetUserAsync(_authState.User)).Id);

            _screenResolutions = await ResolutionsByScreenService.GetByScreen(Id);

            _addingResolution   = false;
            _savingResolution   = false;
            _addingResolutionId = null;

            // Yield thread to let UI to update
            await Task.Yield();

            // Tell we finished loading
            StateHasChanged();
        }
コード例 #2
0
ファイル: Screen.razor.cs プロジェクト: claunia/marechai
        async void ConfirmDelete()
        {
            if (_currentResolution is null)
            {
                return;
            }

            _deleteInProgress = true;

            // Yield thread to let UI to update
            await Task.Yield();

            await ResolutionsByScreenService.DeleteAsync(_currentResolution.Id,
                                                         (await UserManager.GetUserAsync(_authState.User)).Id);

            _screenResolutions = await ResolutionsByScreenService.GetByScreen(Id);

            _deleteInProgress = false;
            _frmDelete.Hide();

            // Yield thread to let UI to update
            await Task.Yield();

            // Tell we finished loading
            StateHasChanged();
        }
コード例 #3
0
ファイル: Screen.razor.cs プロジェクト: claunia/marechai
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            if (_loaded)
            {
                return;
            }

            _loaded = true;

            _creating = NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant().
                        StartsWith("admin/screens/create", StringComparison.InvariantCulture);

            if (Id <= 0 &&
                !_creating)
            {
                return;
            }

            _resolutions = await ResolutionsService.GetAsync();

            _model = _creating ? new ScreenViewModel() : await Service.GetAsync(Id);

            _screenResolutions = await ResolutionsByScreenService.GetByScreen(Id);

            _authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();

            _editing = _creating || NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant().
                       StartsWith("admin/screens/edit/",
                                  StringComparison.InvariantCulture);

            if (_editing)
            {
                SetCheckboxes();
            }

            StateHasChanged();
        }