protected override async Task OnAfterRenderAsync(bool firstRender) { if (_loaded) { return; } _loaded = true; _creating = NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). StartsWith("admin/sound_synths/create", StringComparison.InvariantCulture); if (Id <= 0 && !_creating) { return; } _companies = await CompaniesService.GetAsync(); _model = _creating ? new SoundSynthViewModel() : await Service.GetAsync(Id); _authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); _editing = _creating || NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). StartsWith("admin/sound_synths/edit/", StringComparison.InvariantCulture); if (_editing) { SetCheckboxes(); } StateHasChanged(); }
async void OnCancelClicked() { _editing = false; if (_creating) { NavigationManager.ToBaseRelativePath("admin/sound_synths"); return; } _model = await Service.GetAsync(Id); SetCheckboxes(); StateHasChanged(); }
void ModalClosing(ModalClosingEventArgs obj) => _soundSynth = null;
void ShowModal(int itemId) { _soundSynth = _soundSynths.FirstOrDefault(n => n.Id == itemId); _frmDelete.Show(); }
async void OnSaveClicked() { if (_unknownCompany) { _model.CompanyId = null; } else if (_model.CompanyId < 0) { return; } if (_unknownModelCode) { _model.ModelCode = null; } else if (string.IsNullOrWhiteSpace(_model.ModelCode)) { return; } if (_unknownIntroduced) { _model.Introduced = null; } else if (_prototype) { _model.Introduced = new DateTime(1000, 1, 1); } else if (_model.Introduced >= DateTime.UtcNow.Date) { return; } if (_unknownVoices) { _model.Voices = null; } else if (_model.Voices < 0) { return; } if (_unknownSampleRate) { _model.Frequency = null; } else if (_model.Frequency < 0) { return; } if (_unknownSampleResolution) { _model.Depth = null; } else if (_model.Depth < 0) { return; } if (_unknownSquareWaveChannels) { _model.SquareWave = null; } else if (_model.SquareWave < 0) { return; } if (_unknownWhiteNoiseChannels) { _model.WhiteNoise = null; } else if (_model.WhiteNoise < 0) { return; } if (_unknownType) { _model.Type = null; } else if (_model.Type < 0) { return; } if (_creating) { Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); } else { await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id); } _editing = false; _creating = false; _model = await Service.GetAsync(Id); SetCheckboxes(); StateHasChanged(); }