Ejemplo n.º 1
0
        private async Task HandleSubmit()
        {
            if (_editContext.Validate())
            {
                IsLoadingCircle = true;

                var client = await Http.PostAsJsonAsync(Constants.URI.Berita.Register, new CreateBeritaRequest
                {
                    UserID      = Model.UserID,
                    Title       = Model.Title,
                    Description = Model.Description
                });

                Response = Task.FromResult(await client.Content.ReadFromJsonAsync <ApiResponse <CreateBeritaResponse> >()).Result;

                if (!Response.Status.IsError)
                {
                    await uploadFileAsync(Response.Result.BeritaID, Constants.FileEntityType.Berita);

                    IsLoadingCircle = false;

                    await DialogIsOpenStatus.InvokeAsync(false);

                    await OnSuccessSubmit.InvokeAsync(true);

                    StateHasChanged();
                }
                else
                {
                    Toaster.Add(Response.Status.Message, MatToastType.Danger);

                    IsLoadingCircle = false;
                    StateHasChanged();
                }
            }
            else
            {
                _editContext.AddDataAnnotationsValidation();
                Toaster.AddErrors(_editContext.GetValidationMessages());
            }
        }
Ejemplo n.º 2
0
        private async Task HandleSubmit()
        {
            if (_editContext.Validate())
            {
                IsLoadingCircle = true;

                var client = await Http.PostAsJsonAsync(Constants.URI.UphGmp.Register, new CreateUphGmpRequest
                {
                    UphID = Model.UphID,

                    nama_gmps = Model.nama_gmps,
                });

                Response = Task.FromResult(await client.Content.ReadFromJsonAsync <ApiResponse <CreateUphGmpResponse> >()).Result;

                if (!Response.Status.IsError)
                {
                    IsLoadingCircle = false;

                    await DialogIsOpenStatus.InvokeAsync(false);

                    await OnSuccessSubmit.InvokeAsync(true);

                    StateHasChanged();
                }
                else
                {
                    Toaster.Add(Response.Status.Message, MatToastType.Danger);

                    IsLoadingCircle = false;
                    StateHasChanged();
                }
            }
            else
            {
                _editContext.AddDataAnnotationsValidation();
                Toaster.AddErrors(_editContext.GetValidationMessages());
            }
        }
Ejemplo n.º 3
0
 public void CancelClick() => DialogIsOpenStatus.InvokeAsync(false);