Ejemplo n.º 1
0
        protected override async Task OnInitializedAsync()
        {
            Guid guidFromParams = Guid.Empty;

            try
            {
                guidFromParams = new Guid(Id);
                Poll           = await GetPollByIdAsync(guidFromParams);
            }
            catch (Exception e)
            {
                // When Guid creation or http call fails
                Poll = null;
            }

            if (Poll != null)
            {
                _pollHubService = new PollHubService(NavigationManager.ToAbsoluteUri("/pollhub").ToString());
                await _pollHubService.StartPollHubConnection(Poll);

                _pollHubService.PollChanged += async(poll) => await VisualizePollChild.UpdatePoll(poll);
            }

            var pageCount = (double)Poll.Comments.Count() / PageSize;
            var lastPage  = pageCount == 0 ? 1 : (int)Math.Ceiling(pageCount);

            await LoadPaginatedComments(lastPage);
        }