protected void btnThisHelped_Click(object sender, EventArgs e)
        {
            if (IsUserLoggedIn)
            {
                var currentMember = this.CurrentMember;
                ActivityLog log = new ActivityLog();
                LinkButton btn = (LinkButton)(sender);
                string ids = btn.CommandArgument;
                string[] s = ids.Split('&');
                Guid? ContentId = s[0].AsNGuid();
                string contentTypeId = s[1];
                Guid MemberId = this.CurrentMember.MemberId;
                if (ContentId.HasValue && !(log.FoundItemHelpful(ContentId.Value, MemberId)))
                {
                    // instantiate MM
                    MembershipManager mgr = new MembershipManager();
                    // write to the DB
                    mgr.LogMemberHelpfulVote(MemberId, ContentId.Value, Constants.UserActivity_Values.FoundHelpful_True, Constants.UserActivity_Types.FoundHelpfulVote);
                    Response.Redirect(Request.RawUrl);
                    
                }
            }

            else
            {
                //this.ProfileRedirect(Constants.UserPermission.CommunityUser);
            }

            //var webClient = new WebClient();

            //// replace the "admin" and "Admin's API key" with your valid user and apikey!
            //var adminKey = String.Format("{0}:{1}", Settings.GetSetting(Constants.Settings.TelligentAdminApiKey), "admin");
            //var adminKeyBase64 = Convert.ToBase64String(Encoding.UTF8.GetBytes(adminKey));

            //webClient.Headers.Add("Rest-User-Token", adminKeyBase64);
            //webClient.Headers.Add("Rest-Impersonate-User", this.CurrentMember.ScreenName.Trim());
            //var requestUrl = String.Format("{0}api.ashx/v2/likes.xml", Settings.GetSetting(Constants.Settings.TelligentConfig));

            //var values = new NameValueCollection();
            //values.Add("ContentId", contentId);
            //values.Add("ContentTypeId", contentTypeId);

            //var xml = Encoding.UTF8.GetString(webClient.UploadValues(requestUrl, values));

            //Console.WriteLine(xml);
        }
        protected void VoteNo()
        {
            MembershipManager mmgr = new MembershipManager();
            try
            {

                bool success = mmgr.LogMemberHelpfulVote(CurrentMember.MemberId,
                    context.ID.ToGuid(),
                    Constants.UserActivity_Values.FoundHelpful_False,
                    Constants.UserActivity_Types.FoundHelpfulVote);

                if (success)
                {
                    btnNo.Attributes.Add("class", "button helpful-no");
                    btnSmallNo.Attributes.Add("class", "button helpful-no");
                    btnYes.Attributes.Add("class", "helpful-yes");
                    btnSmallYes.Attributes.Add("class", "helpful-yes");
                    Response.Redirect(Request.RawUrl);
                }
            }
            catch
            {

            }
        }
        protected void btnDidntHelp_Click(object sender, EventArgs e)
        {
            if (IsUserLoggedIn)
            {
                var currentMember = this.CurrentMember;
                ActivityLog log = new ActivityLog();
                LinkButton btn = (LinkButton)(sender);
                string ids = btn.CommandArgument;
                string[] s = ids.Split('&');
                Guid? ContentId = s[0].AsNGuid();
                string contentTypeId = s[1];
                Guid MemberId = this.CurrentMember.MemberId;
                if (ContentId.HasValue && !(log.FoundItemNotHelpful(ContentId.Value, MemberId)))
                {
                    // instantiate MM
                    MembershipManager mgr = new MembershipManager();
                    // write to the DB
                    mgr.LogMemberHelpfulVote(MemberId, ContentId.Value, Constants.UserActivity_Values.FoundHelpful_False, Constants.UserActivity_Types.FoundHelpfulVote);
                    Response.Redirect(Request.RawUrl);
                }
                //ActivityLog log = new ActivityLog();
                //LinkButton btn = (LinkButton)(sender);
                //string ids = btn.CommandArgument;
                //string[] s = ids.Split('&');
                //Guid ContentId = new Guid(s[0]);
                //string contentTypeId = s[1];
                //Guid MemberId = this.CurrentMember.MemberId;


                //if ((log.FoundItemHelpful(ContentId, MemberId)))
                //{
                //    // instantiate MM
                //    MembershipManager mgr = new MembershipManager();
                //    // write to the DB
                //    mgr.LogMemberHelpfulVote(MemberId, ContentId, Constants.UserActivity_Values.FoundHelpful_False, Constants.UserActivity_Types.FoundHelpfulVote);
                //    Response.Redirect(Request.RawUrl);
                //}
            }
            else
            {
                //this.ProfileRedirect(Constants.UserPermission.CommunityUser);
            }

            //var like = new LikeModel();
            //if (!string.IsNullOrEmpty(username))
            //{
            //    like = CommunityHelper.GetLike(this.CurrentMember.ScreenName.Trim(), contentId, contentTypeId);
            //}
            //using (var webClient = new WebClient())
            //{
            //    try
            //    {
            //        // replace the "admin" and "Admin's API key" with your valid user and apikey!
            //        var adminKey = String.Format("{0}:{1}", Settings.GetSetting(Constants.Settings.TelligentAdminApiKey), "admin");
            //        var adminKeyBase64 = Convert.ToBase64String(Encoding.UTF8.GetBytes(adminKey));

            //        webClient.Headers.Add("Rest-User-Token", adminKeyBase64);
            //        webClient.Headers.Add("Rest-Method", "DELETE");

            //        var requestUrl = String.Format("{0}api.ashx/v2/likes.xml", Settings.GetSetting(Constants.Settings.TelligentConfig));

            //        var values = new NameValueCollection();
            //        values.Add("ContentUrl", like.ContentUrl);

            //        var xml = Encoding.UTF8.GetString(webClient.UploadValues(requestUrl, values));

            //        Console.WriteLine(xml);
            //    }
            //    catch { } //TODO: Add logging
            //}
        }
Пример #4
0
        protected void btnLogHelpfulQuestion_Click(object sender, EventArgs e)
        {
            Member m = new Member();
            m.MemberId = Guid.Parse("93e4c02c-3d3d-4ccd-95a3-180bb513e543"); //throw away user
            
            MembershipManager mgr = new MembershipManager();
            mgr.LogMemberHelpfulVote(m.MemberId , Guid.NewGuid(), 
                Constants.UserActivity_Values.FoundHelpful_True, 
                Constants.UserActivity_Types.FoundHelpfulVote,
                Constants.UserActivity_SpecialFilters.QA_QuestionWasHelpful );
            

        }