public ActionResult SongDetails(int songId) { if (Services.WorkContext.CurrentUser.UserName == "admin") { var song = _songService.GetSong(songId); var pollChoiceRecordId = song.PollChoiceRecord_Id; var poll = _pollService.GetPollFromChoiceId(pollChoiceRecordId); var songVotes = _pollService.GetSongVotes(poll.Id, pollChoiceRecordId); var songResult = _pollService.GetSongResult(pollChoiceRecordId); var userVotes = new List <SongVoteEntry>(); var songTitleAndAuthor = song.SongTitle + " (" + song.SongAuthor + ")"; foreach (var vote in songVotes) { // var results = new Dictionary<DateTime, int>(); var songVotesEnteredByUser = _pollService.GetUserVotesForSong(poll.Id, vote.Username, pollChoiceRecordId); var userFullName = "x"; if (vote.Username == "Anonymous") { userFullName = "Anonymous"; } else { // get user fullname from vote record via artist service userFullName = _artistUserService.GetFullName(vote.Username); } var entry = new SongVoteEntry { UserFullName = userFullName, NumberOfVotesByUser = songVotesEnteredByUser.ToList() }; userVotes.Add(entry); } var model = new SongDetailsViewModel { VotesByUser = userVotes, SongTitleAndAuthor = songTitleAndAuthor }; return(View(model)); } else { Services.Notifier.Information(T("Please log in as Admin user in order to access this method.")); return(Redirect("~/Endpoint")); } }
// GET Modal signup screen public ActionResult RegisterModalPopUp(string userName, int eventItemId) { var participants = _eventService.GetEventParticipants(eventItemId).ToList(); // check if user is already registered for event bool isRegistered = false; foreach (var p in participants) { if (p.UserName == userName) { isRegistered = true; } } if (!isRegistered) { var participantName = ""; var participantProfileId = 0; if (userName == "admin") { participantName = "Rose Mary, the Admin"; } else { // get artist username and profile id for display / linkage from _artistService participantName = _artistUserService.GetFullName(userName); } participantProfileId = _artistUserService.GetArtistProfileId(userName); // ready model for submit screen var model = new RegisterParticipantVM { UserName = userName, ParticipantProfileId = participantProfileId, ParticipantName = participantName, Comment = "", EventId = eventItemId }; return(View("Event/RegisterModal", model)); } return(View("Event/RegisterModalNoEntry")); }