public async Task <string> PostAnalyticAsync(AddAnalyticCommand command) { var response = await this._httpClient.PostAsJsonAsync(AnalyticsEndpoint.Create, command); var clientId = response.IsSuccessStatusCode ? await response.Content.ReadAsStringAsync() : string.Empty; return(clientId); }
public async Task OnValidSubmit() { Success = true; StateHasChanged(); if (this.Analytic.Id != Guid.Empty) { var analytic = new EditAnalyticCommand { Id = this.Analytic.Id, Key = this.Analytic.Key, Dimension = this.Analytic.Dimension }; bool success = await _microscopeClient.PutAnalyticAsync(analytic.Id, analytic); if (success) { _snackBar.Add("Analytic updated", Severity.Success); MudDialog.Close(DialogResult.Ok(this.Analytic)); } else { _snackBar.Add("Error", Severity.Error); MudDialog.Close(DialogResult.Cancel()); } } else { var analytic = new AddAnalyticCommand { Key = this.Analytic.Key, Dimension = this.Analytic.Dimension }; string id = await _microscopeClient.PostAnalyticAsync(analytic); if (!string.IsNullOrEmpty(id)) { this.Analytic.Id = Guid.Parse(id); _snackBar.Add("Analytic added", Severity.Success); MudDialog.Close(DialogResult.Ok(this.Analytic)); } else { _snackBar.Add("Error", Severity.Error); MudDialog.Close(DialogResult.Cancel()); } } }
public async Task <ActionResult <Analytic> > PostAnalytic(AddAnalyticCommand command) { Guid idCreated = await this._mediator.Send(command); return(CreatedAtAction("GetAnalytic", new { id = idCreated }, idCreated.ToString())); }