public ActionResult AdminIndex() { BusinessLayer bal = new BusinessLayer(); User currentLogged = bal.GetUserByUsername(User.Identity.Name); if (bal.IsUserAlreadyVoted(currentLogged.UserID)) { VoteListViewModel vlvm = new VoteListViewModel(); vlvm.VoteViewModels = this.GetVoteViewModel(bal.GetVotes()); return(View("VotingResultsAdmin", vlvm)); } int userID = bal.GetBirthdayUserID(); User birthdayUser = bal.GetUserById(userID); UserViewModel uvm = new UserViewModel(birthdayUser.UserID, birthdayUser.Username, birthdayUser.Birthdate); PresentListViewModel plvm = new PresentListViewModel(); plvm.Presents = this.GetPresentsViewModel(bal.GetPresents()); VotingUserViewModel vvm = new VotingUserViewModel(); vvm.User = uvm; vvm.Presents = plvm; //bal.InitializeVoting(currentLogged.UserID, birthdayUser.UserID); return(View("IndexAdmin", vvm)); }
public IActionResult List(string chamber) { ViewData["chamber"] = chamber; var response = client.Get <Response <RecentVotesResult> >($"congress/{chamber}/votes/recent"); var votes = _mapper.Map <List <VoteViewModel> >(response.results.votes); var labels = votes.Select(v => v.result).Distinct(); var data = new List <int>(); labels.ToList().ForEach(x => data.Add(votes.Count(c => c.result == x))); var model = new VoteListViewModel(votes, labels, data); return(PartialView("_List", model)); }
public ActionResult VotingResults() { int presentID = Convert.ToInt32(Request.Form["Present"]); BusinessLayer bal = new BusinessLayer(); User currentLogged = bal.GetUserByUsername(User.Identity.Name); bal.VoteForPresent(currentLogged.UserID, presentID); VoteListViewModel vlvm = new VoteListViewModel(); vlvm.VoteViewModels = this.GetVoteViewModel(bal.GetVotes()); return(View("VotingResults", vlvm)); }