public async Task <IActionResult> Edit(string pollId, string editorId)
        {
            var pollDto = await _pollRepository.Select(pollId);

            PollBuilderViewModel pollBuilderViewModel = new PollBuilderViewModel
            {
                PollId      = pollId,
                EditorToken = editorId,
                Host        = _requestHeaderHandler.GetHost(ControllerContext)
            };

            if (pollDto == null)
            {
                return(NotFound());
            }
            if (pollDto.EditorToken != editorId)
            {
                return(BadRequest());
            }
            if (pollDto.IsPublished)
            {
                pollBuilderViewModel = new PollBuilderViewModel()
                {
                    Title          = pollDto.Title,
                    IsSingleOption = pollDto.IsSingleOption,
                    IsPublished    = pollDto.IsPublished,
                    PollId         = pollDto.PollId,
                    EditorToken    = pollDto.EditorToken,
                    Options        = await _pollOptionRepository.SelectAllForPollPk(pollDto.PrimaryKey),
                    Host           = _requestHeaderHandler.GetHost(ControllerContext)
                };
            }
            return(View("Edit", pollBuilderViewModel));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Index()
        {
            HomePageViewModel homePageViewModel = new HomePageViewModel
            {
                TopFivePolls = await _voteRepository.GetTopFivePolls(),
                Host         = _requestHeaderHandler.GetHost(ControllerContext)
            };

            return(View("Index", homePageViewModel));
        }