Example #1
0
        protected void lvAnswerList_OnItemCommand(object sender, ListViewCommandEventArgs e)
        {
            QuestAnsBAL AnsBAL = new QuestAnsBAL();
            QuestAnsBE  Ans    = new QuestAnsBE();

            if (Session["LoggedInUser"] != null)
            {
                Ans.LastModifiedBy = ((UserBE)Session["LoggedInUser"]).UserId;
            }
            else
            {
                Response.Redirect("~/Login.aspx");
            }
            LoggedIn master = (LoggedIn)this.Master;

            if (String.Equals(e.CommandName, "like"))
            {
                Ans.AnsId   = Convert.ToInt32(e.CommandArgument);
                Ans.QuestId = Convert.ToInt32(hdnQuestId.Value);
                Ans.Like    = 1;
                Ans.DisLike = 0;

                if (AnsBAL.AddLike(Ans))
                {
                    GetAnswers();
                    master.ShowMessage("Successfully liked.", true);
                }
                else
                {
                    master.ShowMessage("you have already liked this answer.", false);
                }
            }
            else if (String.Equals(e.CommandName, "dislike"))
            {
                Ans.AnsId   = Convert.ToInt32(e.CommandArgument);
                Ans.QuestId = Convert.ToInt32(hdnQuestId.Value);
                Ans.Like    = 0;
                Ans.DisLike = 1;

                if (AnsBAL.AddDisLike(Ans))
                {
                    GetAnswers();

                    master.ShowMessage("Successfully dislike.", true);
                }
                else
                {
                    master.ShowMessage("you have already disliked this answer.", false);
                }
            }
        }
        protected void lvAnswerList_OnItemCommand(object sender, ListViewCommandEventArgs e)
        {
            QuestAnsBAL AnsBAL = new QuestAnsBAL();
            QuestAnsBE  Ans    = new QuestAnsBE();

            Ans.LastModifiedBy = ((UserBE)Session["LoggedInUser"]).UserId;
            LoggedIn master = (LoggedIn)this.Master;

            if (String.Equals(e.CommandName, "like"))
            {
                Ans.AnsId   = Convert.ToInt32(e.CommandArgument);
                Ans.QuestId = Convert.ToInt32(hdnQuestId.Value);
                Ans.Like    = 1;
                Ans.DisLike = 0;

                if (AnsBAL.AddLike(Ans))
                {
                    GetAnswers();
                    master.ShowMessage("Successfully liked.", true);
                }
                else
                {
                    master.ShowMessage("You are the author of this answer so can not Like or Dislike it", false);
                }
            }
            else if (String.Equals(e.CommandName, "dislike"))
            {
                Ans.AnsId   = Convert.ToInt32(e.CommandArgument);
                Ans.QuestId = Convert.ToInt32(hdnQuestId.Value);
                Ans.Like    = 0;
                Ans.DisLike = 1;

                if (AnsBAL.AddDisLike(Ans))
                {
                    GetAnswers();

                    master.ShowMessage("Successfully dislike.", true);
                }
                else
                {
                    master.ShowMessage("You are the author of this answer so can not Like or Dislike it.", false);
                }
            }
        }