Exemplo n.º 1
0
        public async Task LoadSessionAsync(Event @event)
        {
            IsBusy = true;
            _event = @event;
            var repositoryResponse = await _sessionRepository.GetSessionsAsync(_event);

            if (repositoryResponse.IsSuccesfull is false)
            {
                await ShutdownDialogHandleAsync("Nie można załadować sesji.");

                IsBusy = false;
                return;
            }

            var sessions = repositoryResponse.Value.ToList();

            if (sessions.IsNullOrEmpty())
            {
                var session  = new Session(@event, $"{Constants.Sessions.NewSessionNameBase}1");
                var response = await _sessionRepository.AddSessionAsync(session);

                sessions.Add(session);

                if (response.IsSuccesfull is false)
                {
                    await ShutdownDialogHandleAsync("Nie można załadować sesji.");

                    IsBusy = false;
                    return;
                }
            }

            CurrentSession = sessions.Find(x => x.Id == _applicationCache.LastChoosenSession) ?? sessions[0];
            IsBusy         = false;
        }
Exemplo n.º 2
0
        private async Task AddSessionAsync()
        {
            var maxSessionNumber = Sessions
                                   .Select(sessionVM => Constants.Sessions.NewSessionNameRegex.Match(sessionVM.Session.Name))
                                   .Where(match => match.Success)
                                   .Select(match => int.Parse(match.Groups[1].Value))
                                   .DefaultIfEmpty(0)
                                   .Max();
            var nextAvailableNumber = maxSessionNumber + 1;
            var session             = new Session(_event, $"{Constants.Sessions.NewSessionNameBase}{nextAvailableNumber}");
            await _sessionRepository.AddSessionAsync(session).ConfigureAwait(true);

            var sessionVM = new SessionViewModel(session);

            Sessions.Add(sessionVM);
        }