Exemple #1
0
        async Task ConfirmDeleteCompanyByMachine()
        {
            if (_currentCompanyByMagazine is null)
            {
                return;
            }

            _deleteInProgress = true;

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

            await CompaniesByMagazineService.DeleteAsync(_currentCompanyByMagazine.Id,
                                                         (await UserManager.GetUserAsync(_authState.User)).Id);

            _magazineCompanies = await CompaniesByMagazineService.GetByMagazine(Id);

            _deleteInProgress = false;
            _frmDelete.Hide();

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

            // Tell we finished loading
            StateHasChanged();
        }
Exemple #2
0
        async Task ConfirmAddCompany()
        {
            if (_addingCompanyId is null ||
                _addingCompanyId <= 0)
            {
                CancelAddCompany();

                return;
            }

            _savingCompany = true;

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

            await CompaniesByMagazineService.CreateAsync(_addingCompanyId.Value, Id, _addingCompanyRoleId,
                                                         (await UserManager.GetUserAsync(_authState.User)).Id);

            _magazineCompanies = await CompaniesByMagazineService.GetByMagazine(Id);

            _addingCompany   = false;
            _savingCompany   = false;
            _addingCompanyId = null;

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

            // Tell we finished loading
            StateHasChanged();
        }
Exemple #3
0
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            if (_loaded)
            {
                return;
            }

            _loaded = true;

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

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

            _countries = await CountriesService.GetAsync();

            _companies = await CompaniesService.GetAsync();

            _roles = await DocumentRolesService.GetEnabledAsync();

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

            _authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();

            _addingCompanyRoleId = _roles.First().Id;
            _magazineCompanies   = await CompaniesByMagazineService.GetByMagazine(Id);

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

            if (_editing)
            {
                SetCheckboxes();
            }

            StateHasChanged();
        }