Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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());
                }
            }
        }
Ejemplo n.º 3
0
        public async Task <ActionResult <Analytic> > PostAnalytic(AddAnalyticCommand command)
        {
            Guid idCreated = await this._mediator.Send(command);

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