public ActionResult CommentCreate(Guid id, string authorName, string authorEmail, string copy) { var context = PortalCrmConfigurationManager.CreateServiceContext(); var idea = context.CreateQuery("adx_idea").FirstOrDefault(adxIdea => adxIdea.GetAttributeValue <Guid>("adx_ideaid") == id); if (idea == null || !Authorized(context, idea)) { return(new EmptyResult()); } var ideaDataAdapter = new IdeaDataAdapter(idea) { ChronologicalComments = true }; TryAddComment(ideaDataAdapter, authorName, authorEmail, copy); var commentsViewModel = new IdeaCommentsViewModel { Idea = ideaDataAdapter.Select(), Comments = new PaginatedList <IComment>(PaginatedList.Page.Last, ideaDataAdapter.SelectCommentCount(), ideaDataAdapter.SelectComments) }; return(PartialView("Comments", commentsViewModel)); }
private ActionResult GetIdeaView(Entity adxIdeaForum, Entity adxIdea, int?page) { var ideaDataAdapter = new IdeaDataAdapter(adxIdea) { ChronologicalComments = true }; var idea = ideaDataAdapter.Select(); var comments = new PaginatedList <IComment>(page, ideaDataAdapter.SelectCommentCount(), ideaDataAdapter.SelectComments); var ideaViewModel = new IdeaViewModel { IdeaForum = new IdeaForumDataAdapter(adxIdeaForum).Select(), Idea = idea, Comments = new IdeaCommentsViewModel { Comments = comments, Idea = idea } }; return(View("Idea", ideaViewModel)); }
private ActionResult GetIdeaView(Entity adxIdeaForum, Entity adxIdea, int?page) { var ideaDataAdapter = new IdeaDataAdapter(adxIdea) { ChronologicalComments = true }; var idea = ideaDataAdapter.Select(); var comments = FeatureCheckHelper.IsFeatureEnabled(FeatureNames.Feedback) ? new PaginatedList <IComment>(page, ideaDataAdapter.SelectCommentCount(), ideaDataAdapter.SelectComments) : null; var currentIdeaForum = new IdeaForumDataAdapter(adxIdeaForum).Select(); if (currentIdeaForum == null) { return(RedirectToPageNotFound()); } var ideaViewModel = new IdeaViewModel { IdeaForum = currentIdeaForum, Idea = idea, Comments = new IdeaCommentsViewModel { Comments = comments, Idea = idea } }; if (FeatureCheckHelper.IsFeatureEnabled(FeatureNames.TelemetryFeatureUsage)) { PortalFeatureTrace.TraceInstance.LogFeatureUsage(FeatureTraceCategory.Idea, this.HttpContext, "read_idea", 1, idea.Entity.ToEntityReference(), "read"); PortalFeatureTrace.TraceInstance.LogFeatureUsage(FeatureTraceCategory.Idea, this.HttpContext, "read_comment_idea", idea.CommentCount, idea.Entity.ToEntityReference(), "read"); } return(View("Idea", ideaViewModel)); }
private bool TryAddVote(int voteValue, Guid ideaId, out IdeaDataAdapter ideaDataAdapter) { ideaDataAdapter = null; var context = PortalCrmConfigurationManager.CreateServiceContext(); var idea = context.CreateQuery("adx_idea").FirstOrDefault(adxIdea => adxIdea.GetAttributeValue <Guid>("adx_ideaid") == ideaId); if (idea == null || !Authorized(context, idea)) { return(false); } ideaDataAdapter = new IdeaDataAdapter(idea); if (!ideaDataAdapter.Select().CurrentUserCanVote(voteValue)) { return(false); } ideaDataAdapter.CreateVote(voteValue, "Anonymous", "*****@*****.**"); return(true); }