public async Task <IActionResult> GetById([FromRoute] int id)
        {
            var dto = await _pollAnswerService.GetById(id);

            if (!dto.Succeeded)
            {
                return(BadRequest(dto.Errors));
            }

            return(Ok(dto.Result));
        }
Example #2
0
        public int PollVote(List <int> voteIds, int pollId)
        {
            if (voteIds != null)
            {
                foreach (var voteId in voteIds)
                {
                    var answer = _pollAnswerService.GetById(voteId);
                    if (answer != null)
                    {
                        _pollAnswerService.IncreaseVote(answer);
                    }
                }

                var cookieName = string.Format(EzCMSContants.VotedUserCookie, pollId);

                StateManager.GetCookie(cookieName, true, true,
                                       DateTime.Now.AddDays(EzCMSContants.PollCookieExpireDay));

                return(voteIds.Count);
            }
            return(0);
        }