Пример #1
0
        async Task ConfirmDeleteCompanyByMachine()
        {
            if (_currentCompanyBySoftwareFamily is null)
            {
                return;
            }

            _deleteInProgress = true;

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

            await CompaniesBySoftwareFamilyService.DeleteAsync(_currentCompanyBySoftwareFamily.Id,
                                                               (await UserManager.GetUserAsync(_authState.User)).Id);

            _softwareFamilyCompanies = await CompaniesBySoftwareFamilyService.GetBySoftwareFamily(Id);

            _deleteInProgress = false;
            _frmDelete.Hide();

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

            // Tell we finished loading
            StateHasChanged();
        }
Пример #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 CompaniesBySoftwareFamilyService.CreateAsync(_addingCompanyId.Value, Id, _addingCompanyRoleId,
                                                               (await UserManager.GetUserAsync(_authState.User)).Id);

            _softwareFamilyCompanies = await CompaniesBySoftwareFamilyService.GetBySoftwareFamily(Id);

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

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

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

            _loaded = true;

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

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

            _softwareFamilies = await Service.GetAsync();

            _companies = await CompaniesService.GetAsync();

            _roles = await DocumentRolesService.GetEnabledAsync();

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

            _authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();

            _addingCompanyRoleId     = _roles.First().Id;
            _softwareFamilyCompanies = await CompaniesBySoftwareFamilyService.GetBySoftwareFamily(Id);

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

            if (_editing)
            {
                SetCheckboxes();
            }

            StateHasChanged();
        }