public async Task <IActionResult> GetPollValues(long pollId)
        {
            var poll = await _pollService.GetPoll(pollId);

            if (poll == null)
            {
                return(NotFound(Errors.GetSingleErrorList("", _localizer["PollNotFound"])));
            }

            var pollType = poll.GetType();

            if (pollType == typeof(PolicyChangePoll))
            {
                var val = _mapper.Map <PolicyChangePoll, PollListViewModel>((PolicyChangePoll)poll);
                val.ListType = await SetListType(poll);

                return(Ok(val));
            }

            if (pollType == typeof(AuthorityPoll))
            {
                var val = await _pollViewModelService.GetUsersForAuthorityVoting((AuthorityPoll)poll);

                var currentUser = val.Users.FirstOrDefault(x => x.Id == User.ApiGetUserId());
                if (currentUser != null)
                {
                    val.Users.Remove(currentUser);
                }
                val.ListType = await SetListType(poll);

                return(Ok(val));
            }

            if (pollType == typeof(MultipleChoicePoll))
            {
                var val = _pollViewModelService.MultipleChoicePollToViewModel((MultipleChoicePoll)poll);
                val.ListType = await SetListType(poll);

                return(Ok(val));
            }

            if (pollType == typeof(SharePoll))
            {
                var val = _pollViewModelService.SharePollToViewModel((SharePoll)poll);
                val.ListType = await SetListType(poll);

                return(Ok(val));
            }

            return(BadRequest(Errors.GetSingleErrorList("", _localizer["UnknownPoll"])));
        }
        public async Task Should_GetUsersForAuthorityPoll()
        {
            var poll = new AuthorityPoll
            {
                Name       = "AuthorityPoll",
                Active     = true,
                CreateTime = DateTime.UtcNow,
                Deadline   = DateTime.UtcNow.AddDays(2)
            };

            _context.Polls.Add(poll);
            _context.SaveChanges();
            _context.Users.Add(new ApplicationUser
            {
                Email          = "*****@*****.**",
                FirstName      = "test",
                LastName       = "Test",
                CreatedAt      = DateTime.UtcNow,
                SecurityStamp  = new Guid().ToString(),
                EmailConfirmed = false,
                Id             = 1.ToString(),
                IsDeleted      = false,
                UserDetail     = new UserDetail {
                    AuthorityPercent = 1, LanguagePreference = "tr"
                }
            });

            _context.Users.Add(new ApplicationUser
            {
                Email          = "*****@*****.**",
                FirstName      = "Test",
                LastName       = "Test",
                CreatedAt      = DateTime.UtcNow,
                SecurityStamp  = new Guid().ToString(),
                EmailConfirmed = false,
                Id             = 2.ToString(),
                IsDeleted      = false,
                UserDetail     = new UserDetail {
                    AuthorityPercent = 1, LanguagePreference = "tr"
                }
            });
            _context.SaveChanges();
            var result = await _pollApiViewModelService.GetUsersForAuthorityVoting(poll);

            Assert.Equal(2, result.Users.Count);
            Assert.Equal(poll.Id, result.PollId);
            Assert.Equal(poll.Name, result.Name);
        }