Example #1
0
        public async Task <IViewComponentResult> InvokeAsync(int id, string votedName = null)
        {
            ApplicationUser currentLogedInUser = await _userManager.GetUserAsync(HttpContext.User);

            if (!string.IsNullOrEmpty(votedName))
            {
                var model = await _votingService.VoteCast(id, votedName, currentLogedInUser);

                var broadcast_model = new DuoBroadcastModel
                {
                    DuoFirstVotes  = model.DuoFirstVotes,
                    DuoSecondVotes = model.DuoSecondVotes,
                    DuoTotalVotes  = model.DuoTotalVotes
                };
                _connectionManager.GetHubContext <VotingHub>().Clients.All.UpdateVotedDuo(broadcast_model);

                return(View(model));
            }
            else
            {
                var model = await _votingService.GetDuo(id, currentLogedInUser);

                return(View(model));
            }
        }