Esempio n. 1
0
        private async Task EditPathAsync(Path path)
        {
            try
            {
                var result = await PathService.EditPathAsync(path);

                var item = Paths.FirstOrDefault(x => x.Id == result.Id);
                if (item != null)
                {
                    item = result;
                }
                SnackbarHelper.PrintSuccess(localizer["PathUpdated"]);
            }
            catch (ApiError e)
            {
                if (e.ProblemDetails.Status == 422)
                {
                    SnackbarHelper.PrintErrorDetails((e.ProblemDetails as UnprocessableEntityProblemDetails).Errors);
                }
            }
            catch (Exception e)
            {
                SnackbarHelper.PrintError(e.Message);
            }
            StateHasChanged();
        }
Esempio n. 2
0
        private async Task DeletePath(Path pathItem)
        {
            try
            {
                var result = await PathService.DeletePath(pathItem);

                if (result)
                {
                    Paths.Remove(pathItem);
                    SnackbarHelper.PrintWarning(localizer["PathDeleted"]);
                }
                StateHasChanged();
            }
            catch (Exception e)
            {
                SnackbarHelper.PrintError(e.Message);
            }
        }
Esempio n. 3
0
        private async Task LoadDataAsync(int pageNum)
        {
            try
            {
                _lastPageRequest = pageNum;

                _state = State.Loading;
                var result = await PathService.GetListAsync(false, pageNum, PAGE_SIZE);

                Paths = result.Data;
                PaginationMetadata = result.Metadata;
                _state             = State.ContentReady;
            }
            catch (Exception ex)
            {
                SnackbarHelper.PrintError(ex.Message);
                _state = State.Error;
            }
        }
Esempio n. 4
0
        private async Task ChangePathVisibilityAsync(Path pathItem)
        {
            try
            {
                var result = await PathService.ChangeVisibility(pathItem);

                var changed = Paths.FirstOrDefault(x => x.Id == pathItem.Id);
                if (changed != null)
                {
                    changed.IsVisible = result.IsVisible;
                }

                StateHasChanged();
            }
            catch (Exception e)
            {
                SnackbarHelper.PrintError(e.Message);
            }
        }
Esempio n. 5
0
        private async Task AddNewPathAsync(Path resultData)
        {
            try
            {
                var result = await PathService.AddNewPathAsync(resultData);

                Paths.Add(result);
                SnackbarHelper.PrintSuccess(localizer["PathCreated"]);
            }
            catch (ApiError e)
            {
                if (e.ProblemDetails.Status == 422)
                {
                    SnackbarHelper.PrintErrorDetails((e.ProblemDetails as UnprocessableEntityProblemDetails).Errors);
                }
            }
            catch (Exception e)
            {
                SnackbarHelper.PrintError(e.Message);
            }
            StateHasChanged();
        }