Example #1
0
        private async Task SaveFlag(Window window)
        {
            Accepted = Flag != SolveFlagsViewModel.ChoosenFlag;
            if (Accepted is false)
            {
                window.Close();
                return;
            }

            IsBusy = true;

            var response = await _solvesRepository.UpdateSolveAsync(Model);

            if (response.IsSuccesfull is false)
            {
                SolveFlagsViewModel = new SolveFlagsViewModel(Flag);
                IsBusy = false;
                window.Close();
                _snackbarViewModel.EnqueueSchedule("Nie udało się zaaktualizować flagi ułożenia. Błąd przy połączeniu z serwerem.");
                return;
            }

            Model.Flag = SolveFlagsViewModel.ChoosenFlag;
            Flag       = SolveFlagsViewModel.ChoosenFlag;
            UpdateSummary();

            IsBusy = false;
            window.Close();
        }
        private async Task LoadAsync()
        {
            IsBusy = true;
            var repositoryResponse = await _solvesRepository.GetSolvesAsync(_session).ConfigureAwait(false);

            if (repositoryResponse.IsSuccesfull is false)
            {
                _snackbarViewModel.EnqueueSchedule("Podczas ładownia ułożeń wysątpił błąd.");
                IsBusy = false;
                return;
            }

            var ordered = repositoryResponse.Value !.OrderByDescending(solve => solve.Date).Select(solve => new SolveViewModel(solve, _snackbarViewModel, _solvesRepository));

            Solves = new ObservableCollection <SolveViewModel>(ordered);
            Solves.CollectionChanged += UpdateIndexesAsync;
            UpdateIndexesAsync(this, EventArgs.Empty);
            IsBusy = false;
        }