Ejemplo n.º 1
0
        public async Task <string> PostRemoteConfigAsync(AddRemoteConfigCommand command)
        {
            var response = await this._httpClient.PostAsJsonAsync(RemoteConfigsEndpoint.Create, command);

            var clientId = response.IsSuccessStatusCode ? await response.Content.ReadAsStringAsync() : string.Empty;

            return(clientId);
        }
Ejemplo n.º 2
0
        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());
                }
            }
        }
Ejemplo n.º 3
0
        public async Task <ActionResult <RemoteConfig> > PostRemoteConfig(AddRemoteConfigCommand command)
        {
            Guid idCreated = await this._mediator.Send(command);

            return(CreatedAtAction("GetRemoteConfig", new { id = idCreated }, idCreated.ToString()));
        }