public async Task <IActionResult> PutRemoteConfig(Guid id, EditRemoteConfigCommand command) { if (id != command.Id) { return(BadRequest()); } await this._mediator.Send(command); return(Ok()); }
public async Task OnValidSubmit() { Success = true; StateHasChanged(); if (this.RemoteConfig.Id != Guid.Empty) { var remote = new EditRemoteConfigCommand { Id = this.RemoteConfig.Id, Key = this.RemoteConfig.Key, Dimension = this.RemoteConfig.Dimension }; bool success = await _microscopeClient.PutRemoteConfigAsync(this.RemoteConfig.Id, remote); if (success) { _snackBar.Add("Remote Config updated", Severity.Success); MudDialog.Close(DialogResult.Ok(this.RemoteConfig)); } else { _snackBar.Add("Error", Severity.Error); MudDialog.Close(DialogResult.Cancel()); } } else { var remote = new AddRemoteConfigCommand { Key = this.RemoteConfig.Key, Dimension = this.RemoteConfig.Dimension }; string id = await _microscopeClient.PostRemoteConfigAsync(remote); if (!string.IsNullOrEmpty(id)) { this.RemoteConfig.Id = Guid.Parse(id); _snackBar.Add("Remote Config added", Severity.Success); MudDialog.Close(DialogResult.Ok(this.RemoteConfig)); } else { _snackBar.Add("Error", Severity.Error); MudDialog.Close(DialogResult.Cancel()); } } }
public async Task <bool> PutRemoteConfigAsync(Guid id, EditRemoteConfigCommand remoteConfig) { var response = await this._httpClient.PutAsJsonAsync(RemoteConfigsEndpoint.Update(id), remoteConfig); return(response.IsSuccessStatusCode); }