public IActionResult Details(int id) { string userId = null; if (_signInManager.IsSignedIn(User)) { userId = User.FindFirst(ClaimTypes.NameIdentifier).Value; } Ideation ideation = _ideationManager.GetIdeation(id); var ideas = _ideasHelper.GetIdeas(userId, ideation.IdeationId); Dictionary <int, SAVotes> ideaVotes = new Dictionary <int, SAVotes>(); foreach (var idea in ideas) { var anVotes = 0; var veVotes = 0; var usVotes = 0; var realIdea = _ideationManager.GetIdea(idea.IdeaId); foreach (var vote in realIdea.Votes) { if (vote.User != null) { usVotes += vote.Value; } else if (vote.Email != null) { veVotes += vote.Value; } else { anVotes += vote.Value; } } ideaVotes.Add(realIdea.IdeaId, new SAVotes() { anVotes = anVotes, veVotes = veVotes, usVotes = usVotes }); } var model = new IdeationUserVote { ideas = ideas, ideation = ideation, ideaVotes = ideaVotes }; return(View(model)); }
public IActionResult GetIdeas([FromQuery] string userId) { return(Ok(_ideasHelper.GetIdeas(userId))); }