예제 #1
0
        private ActionResult Vote(string id, ForAgainst forAgainst)
        {
            try
            {
                if (IsAjaxRequest)
                {
                    LastVoteReferrerUrl = Request.UrlReferrer;
                }

                var vote = Service.Vote(id, forAgainst);

                if (!IsAjaxRequest)
                {
                    return(RedirectToSuccessAction(MVC.NewsFeed.Default(CurrentUser.LanguageCode), Resource.VoteSuccess, true));
                }

                if (!vote.Vote.HasValue)
                {
                    return(Json(Resource.VotingFinished));
                }

                vote.VotedString = GetVotedString(forAgainst);

                return
                    (Json(
                         new
                {
                    VotingStatistics = RenderPartialViewToString(MVC.Voting.Views.VotingStatistics, vote),
                    Type = EntryTypes.Issue.ToString(),
                    Progress = RenderPartialViewToString(MVC.Voting.Views.Progress, vote),
                    Subscribe = RenderPartialViewToString(MVC.Shared.Views.Subscribe, vote.Subscribe),
                    ThankYou = RenderPartialViewToString(MVC.Voting.Views.ButtonThankYou)
                }));
            }
            catch (AdditionalUniqueInfoRequiredException ex)
            {
                if (IsAjaxRequest)
                {
                    var result = ProcessError(ex, false) as JsonpResult;
                    result.Data = new
                    {
                        Error   = ex.GetType().ToString() + ": " + ex.Message,
                        Content = RenderPartialViewToString(MVC.Account.Views.AdditionalUniqueInfoContents, ex.AdditionalInfo)
                    };
                    return(result);
                }

                TempData["OpenAdditinalUniqueInfoDialog"] = ex.AdditionalInfo;
                return(Details(id, null));
            }
            catch (Exception e)
            {
                return(ProcessError(e, false));
            }
        }
예제 #2
0
        public virtual ActionResult OfficialVote(string id, ForAgainst forAgainst, string description)
        {
            var model = Service.OfficialVote(id, forAgainst, description);

            if (Request.HttpMethod == "GET" || !Request.IsAjaxRequest())
            {
                return(RedirectToAction(MVC.Voting.Details(id, null)));
            }

            return(Json(true));
        }
예제 #3
0
파일: VoteEx.cs 프로젝트: Lietuva2/LT2
 private string[] GetSignValues(string subject, string text)
 {
     return(new[]
     {
         subject,
         text,
         FirstName,
         LastName,
         PersonCode,
         ForAgainst.ToString(),
         Date.ToString("yyyy-MM-dd HH:mm:ss"),
         Source
     });
 }
예제 #4
0
        private static string GetVotedString(ForAgainst pn)
        {
            if (pn == ForAgainst.For)
            {
                return(Resource.VotedFor);
            }

            if (pn == ForAgainst.Against)
            {
                return(Resource.VotedAgainst);
            }

            return(string.Empty);
        }
예제 #5
0
        public virtual CommentView AddNewComment(ICommentable entity, ForAgainst forAgainst, string text, EmbedModel embed, MongoObjectId versionId = null)
        {
            if (CurrentUser.RequireUniqueAuthentication && !CurrentUser.IsUnique)
            {
                throw new UserNotUniqueException();
            }

            if (entity.Id == CurrentUser.Id)
            {
                forAgainst = ForAgainst.Neutral;
            }

            entity.LastNumber++;
            var comment = new Comment
            {
                Date               = DateTime.Now,
                Text               = text,
                UserFullName       = CurrentUser.FullName,
                UserObjectId       = CurrentUser.Id,
                RelatedVersionId   = versionId,
                PositiveOrNegative = forAgainst,
                Number             = entity.LastNumber.ToString() + "."
            };

            if (embed != null && !embed.IsEmpty)
            {
                comment.Embed = new Data.MongoDB.Embed();
                comment.Embed.InjectFrom(embed);

                comment.Embed.Title       = comment.Embed.Title.Sanitize();
                comment.Embed.Description = comment.Embed.Description.Sanitize();
            }
            entity.Comments.Add(comment);
            UpdateEntity(entity);

            var model = GetCommentViewFromComment(entity.Id, comment, null, entity.EntryType,
                                                  entity.GetRelatedVersionNumber(comment.RelatedVersionId));


            model.SubscribeMain = ActionService.Subscribe(entity.Id, CurrentUser.DbId.Value, entity.EntryType);
            model.Subscribe     = ActionService.Subscribe(comment.Id, CurrentUser.DbId.Value);

            return(model);
        }
예제 #6
0
        public static string GetTextCssClass(this HtmlHelper html, ForAgainst forAgainst)
        {
            if (forAgainst == ForAgainst.Neutral)
            {
                return(string.Empty);
            }

            if (forAgainst == ForAgainst.For)
            {
                return("text-for");
            }

            if (forAgainst == ForAgainst.Against)
            {
                return("text-against");
            }

            if (forAgainst == ForAgainst.Suggest)
            {
                return("text-suggest");
            }

            return(string.Empty);
        }
예제 #7
0
        public static string GetBackgroundCssClass(this HtmlHelper html, ForAgainst forAgainst)
        {
            if (forAgainst == ForAgainst.Neutral)
            {
                return(string.Empty);
            }

            if (forAgainst == ForAgainst.For)
            {
                return("background-for");
            }

            if (forAgainst == ForAgainst.Against)
            {
                return("background-against");
            }

            if (forAgainst == ForAgainst.Suggest)
            {
                return("background-suggest");
            }

            return(string.Empty);
        }
예제 #8
0
파일: HtmlHelpers.cs 프로젝트: Lietuva2/LT2
 public static MvcHtmlString GetDecisionClass(this HtmlHelper helper, ForAgainst decision)
 {
     return(MvcHtmlString.Create(decision == ForAgainst.For ? "progessbar-content green-border" : decision == ForAgainst.Against ? "progessbar-content red-border" : "progessbar-content-transparent"));
 }
예제 #9
0
        public virtual CommentView AddNewComment(MongoObjectId id, string text, EmbedModel embed, ForAgainst forAgainst = ForAgainst.Neutral, MongoObjectId versionId = null)
        {
            var entity  = GetEntity(id);
            var comment = commentService.AddNewComment(entity, forAgainst, text, embed, versionId);

            SendCommentCommand(entity, GetAddNewCommentActionType(), comment);
            return(comment);
        }
예제 #10
0
 public int GetCommentsCount(ICommentable entity, ForAgainst forAgainst)
 {
     return(entity.Comments.Count(c => c.PositiveOrNegative == forAgainst));
 }
예제 #11
0
파일: Issue.cs 프로젝트: Lietuva2/LT2
        public static ForAgainst GetDecision(int supportingVotesCount, int nonSupportingVotesCount, ForAgainst officialVote)
        {
            if (officialVote == ForAgainst.Neutral)
            {
                return(ForAgainst.Neutral);
            }

            if (supportingVotesCount > nonSupportingVotesCount && officialVote == ForAgainst.For)
            {
                return(ForAgainst.For);
            }

            if (supportingVotesCount < nonSupportingVotesCount && officialVote == ForAgainst.Against)
            {
                return(ForAgainst.For);
            }

            if (supportingVotesCount > nonSupportingVotesCount && officialVote == ForAgainst.Against)
            {
                return(ForAgainst.Against);
            }

            if (supportingVotesCount < nonSupportingVotesCount && officialVote == ForAgainst.For)
            {
                return(ForAgainst.Against);
            }

            return(ForAgainst.Neutral);
        }