public bool VoteSuggestion(TextMergeSuggestionVoteViewModel voteViewModel)
        {
            var cluster = _db.ResourceClusters.Get(voteViewModel.ClusterId);
            var alreadySuggested =
                cluster.Suggestions.FirstOrDefault(m => m.Votes.Any(v => v.VoteBy.Id == voteViewModel.VoteBy));
            if (alreadySuggested != null)
            {
                var vote = alreadySuggested.Votes.First(v => v.VoteBy.Id == voteViewModel.VoteBy);
                alreadySuggested.Votes.Remove(vote);
            }

            var suggestion = _db.TextMergeSuggestions.Get(voteViewModel.SuggestionId);

            suggestion.Votes.Add(new TextMergeSuggestionVote
            {
                Date = DateTime.Now,
                VoteBy = _db.Users.Get(voteViewModel.VoteBy)
            });

            _db.Save();
            var voteIsDone = CheckVoteIsDone(voteViewModel.NodeId, voteViewModel.ClusterId);

            if (voteIsDone)
            {
                TextMergeSuggestion winner = cluster.Suggestions.First();//cluster.Suggestions.FirstOrDefault(sugestion => sugestion.Votes.Count);
                var maxVotes = 0;
                foreach (var suggestions in cluster.Suggestions)
                {
                    if (suggestions.Votes.Count > maxVotes)
                    {
                        winner = suggestions;
                        maxVotes = suggestions.Votes.Count;
                    }
                }

                winner.Status = TextSuggestionStatus.Approved;

                var combined = _db.NodeResources.GetAll().Where(m => m.Id == winner.FirstResourceId || m.Id == winner.SecondResourceId);

                foreach (var resource in combined)
                {
                    resource.IsDeleted = true;
                }
                var winnerResource = new NodeResource
                {
                    AddBy = winner.SuggestedBy,
                    Date = DateTime.Now,
                    Cluster = cluster,
                    ResourceRaw = winner.Value,
                    Resource = winner.Value.StripHtml(),
                    Node = _db.Nodes.Get(voteViewModel.NodeId),
                    TextName = string.Join("-", combined.Select(m => m.TextName))
                };

                var merged = cluster.MergeResults.FirstOrDefault(
                    m => m.FirstResourceId == winner.FirstResourceId && m.SecondResourceId == winner.SecondResourceId);
                cluster.MergeResults.Remove(merged);

                var next = cluster.MergeResults.FirstOrDefault();

                _db.NodeResources.Create(winnerResource);
                _db.Save();
                if (next != null)
                {
                    if (next.FirstResourceId.HasValue == false)
                    {
                        next.FirstResourceId = winnerResource.Id;
                    }

                    if (next.SecondResourceId.HasValue == false)
                    {
                        next.SecondResourceId = winnerResource.Id;
                    }
                }
                _db.Save();
            }

            return voteIsDone;
        }
 public bool VoteTextMergeSuggestion(TextMergeSuggestionVoteViewModel voteViewModel)
 {
     return _textMergeSuggestionService.VoteSuggestion(voteViewModel);
 }