Пример #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();
        }
Пример #2
0
        public SolveViewModel(
            Solve solve,
            SnackbarViewModel snackbarViewModel,
            ISolvesRepository solvesSaver)
        {
            _snackbarViewModel = snackbarViewModel;
            _solvesRepository  = solvesSaver;

            Model    = solve;
            Time     = solve.TimeAsSpan;
            Flag     = solve.Flag;
            Date     = solve.Date;
            Scramble = solve.Scramble;

            SolveFlagsViewModel = new SolveFlagsViewModel(solve.Flag);

            EditSolveCommand = ReactiveCommand.CreateFromTask <Window>(EditSolve);
            AcceptCommand    = ReactiveCommand.CreateFromTask <Window>(SaveFlag);

            UpdateSummary();
        }