Exemple #1
0
        //Thanks by json
        public JsonResult ThanksButtonClick(int PostId, int x, int Flag)
        {
            int Existance = db.ThanksButtons.Where(w => w.PostId == PostId && w.UserId == x && w.Flag == Flag).Count();

            if (Existance > 0)
            {
                var FindThanker = db.ThanksButtons.Where(w => w.PostId == PostId && w.UserId == x && w.Flag == Flag).FirstOrDefault();
                db.ThanksButtons.Remove(FindThanker);

                db.SaveChanges();
                int CountAll = db.ThanksButtons.Where(w => w.PostId == PostId).Count();
                //save thanks and count here 0==show Save and Button show thanks
                //make unThanks
                ThanksReturnValues _aValues = new ThanksReturnValues();
                _aValues.ThanksCount = CountAll;
                _aValues.Status      = 0;
                return(Json(_aValues, JsonRequestBehavior.AllowGet));
            }
            else
            {
                //save thanks and count here 1==show Save and Button show Unthanks
                ThanksButton _thanks = new ThanksButton {
                    Thanks = 1, UserId = x, PostId = PostId, Flag = Flag
                };
                db.ThanksButtons.Add(_thanks);
                db.SaveChanges();
                int CountAll = db.ThanksButtons.Where(w => w.PostId == PostId).Count();
                ThanksReturnValues _aValues = new ThanksReturnValues();
                _aValues.ThanksCount = CountAll;
                _aValues.Status      = 1;

                return(Json(_aValues, JsonRequestBehavior.AllowGet));
            }
        }
Exemple #2
0
        // GroupDiscussionList rptGroupDiscussion;

        protected void Page_Load(object sender, EventArgs e)
        {
            lbSubmitReply.Text = DictionaryConstants.SubmitButtonText;

            //  rptGroupDiscussion = (GroupDiscussionList)Page.LoadControl("~/Presentation/Sublayouts/Common/GroupDiscussionList.ascx");
            //   rptGroupDiscussion.ID = "rptGroupCards";
            //   plhGroupDiscussions.Controls.Add(rptGroupDiscussion);

            //if (!IsPostBack)
            //{
            txtBody.Attributes.Add("placeholder", "Join the discussion");
            txtBody.Attributes.Add("id", "join-discussion-text");



            Item currItem = Sitecore.Context.Item;

            if (currItem != null)
            {
                hrfBack.HRef = LinkManager.GetItemUrl(currItem.Parent);
                litBack.Text = currItem.Parent.Name;
                GroupDiscussionItem grpDItem = new GroupDiscussionItem(currItem);
                if (grpDItem != null)
                {
                    Session["discussionItem"] = grpDItem;
                    string forumID  = grpDItem.ForumID.Text;
                    string threadID = grpDItem.ThreadID.Text;
                    try
                    {
                        ThreadModel thModel = UnderstoodDotOrg.Services.CommunityServices.Threads.ThreadModelFactory(forumID, threadID);

                        //Populate the initial Post
                        ProfileCommentCard.LoadState(thModel.Author);

                        rptGroupDiscussion.DataSource = thModel.Replies;
                        rptGroupDiscussion.DataBind();

                        if (thModel.Author != null)
                        {
                            ThanksButton.LoadState(thModel.Author.UserName);
                            ThinkingOfYouButton.LoadState(thModel.Author.UserName);
                        }

                        lblSubject.Text = thModel.Subject;

                        litComment.Text    = thModel.Body;
                        litNumReplies.Text = thModel.ReplyCount;
                        LikeButton.LoadState(thModel.ContentId, thModel.ContentTypeId);
                        litMemberCount.Text = thModel.Replies.Select(m => m.AuthorName).Distinct().Count().ToString();
                    }
                    catch (Exception ex)
                    {
                        Sitecore.Diagnostics.Error.LogError("Error Retrieving replies Page_Load Parent Group Discussions.\nError" + ex.Message);
                    }
                }
            }
            //}
        }