示例#1
0
        private void OnSessionDelete(NotifyCollectionChangedEventArgs e, SessionChangeViewModel sessionChangeViewModel)
        {
            if (e.Action != NotifyCollectionChangedAction.Remove)
            {
                return;
            }

            foreach (SessionViewModel session in e.OldItems)
            {
                if (CurrentSession.Id != session.Session.Id)
                {
                    continue;
                }
                CurrentSession = sessionChangeViewModel.Sessions[0].Session;
                break;
            }
        }
示例#2
0
        private async Task ChangeSessionAsync()
        {
            var sessionChangeViewModel = new SessionChangeViewModel(_event, _sessionRepository);
            var contructed             = await sessionChangeViewModel.ConstructAsync().ConfigureAwait(true);

            if (contructed is false)
            {
                await CloseWindowDialogHandleAsync("Nie można załadować sesji");

                return;
            }

            sessionChangeViewModel.AcceptRenameSessionCommand.Subscribe(UpdateSessionIfNameChanged);
            sessionChangeViewModel.Sessions.CollectionChanged += (_, o) => OnSessionDelete(o, sessionChangeViewModel);

            var result = await ShowSessionChangeDialog.Handle(sessionChangeViewModel);

            if (result is not null && result.Session.Id != CurrentSession.Id)
            {
                CurrentSession = result.Session;
                _applicationCache.LastChoosenSession = CurrentSession.Id !;
                await _applicationCacheSaver.SaveCacheAsync(_applicationCache).ConfigureAwait(true);
            }
        }