Beispiel #1
0
        public IdeaDto GetIdea(int ideaId, string userId)
        {
            try
            {
                var idea = _ideationManager.GetIdea(ideaId);
                if (idea == null)
                {
                    throw new ArgumentException("Idea not found", "ideaId");
                }

                var dto = _mapper.Map <IdeaDto>(idea);

                var vote = _userManager.GetVoteForIdea(ideaId, userId);
                if (vote != null)
                {
                    dto.UserVoteValue = vote.Value;
                }

                dto.Comments = _commentsHelper.GetCommentsForIdea(idea.IdeaId, userId);

                return(dto);
            }
            catch (Exception e)
            {
                throw new Exception($"Something went wrong in getting the comment: {e.Message}.");
            }
        }
        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));
        }
Beispiel #3
0
        public IActionResult ConfirmVote(int id)
        {
            var idea = _ideationManager.GetIdea(id);

            return(View(idea));
        }