Esempio n. 1
0
        protected void LikeButton_Click(object sender, EventArgs e)
        {
            if (!Context.User.Identity.IsAuthenticated)
            {
                FormsAuthentication.RedirectToLoginPage();
                return;
            }

            DomainHelper.CheckForDomain(Settings.Default.PetBoardFriendsDomain, _simpleDBClient);
            string ip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

            if (!String.IsNullOrEmpty(ip))
            {
                string[] ipRange = ip.Split(',');
                int      le      = ipRange.Length - 1;
                string   trueIP  = ipRange[le];
            }
            else
            {
                ip = Request.ServerVariables["REMOTE_ADDR"];
            }

            PutAttributesRequest request = new PutAttributesRequest()
            {
                DomainName = Settings.Default.PetBoardFriendsDomain,
                ItemName   = ip,
                Attributes = new List <ReplaceableAttribute>()
                {
                    new ReplaceableAttribute
                    {
                        Name    = "Member",
                        Value   = this.Context.User.Identity.Name,
                        Replace = true
                    },
                    new ReplaceableAttribute
                    {
                        Name    = "Pet",
                        Value   = this._petIdString,
                        Replace = true
                    }
                }
            };

            _simpleDBClient.PutAttributes(request);
            this.Response.Redirect(this.Request.RawUrl);
        }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this._petIdString = this.Request.QueryString["petid"];

            if (!String.IsNullOrEmpty(this._petIdString))
            {
                this._itemName   = this._petIdString ?? Guid.NewGuid().ToString();
                this._domainName = String.Format(Settings.Default.SimpleDbDomainNameFormat, this.Context.User.Identity.Name);

                UpdatePageWithPetInformation(RetrievePetFromPrivateDomain());

                DomainHelper.CheckForDomain(Properties.Settings.Default.PetBoardFriendsDomain, _simpleDBClient);
                SelectRequest selectRequest = new SelectRequest()
                {
                    SelectExpression = String.Format("select * from `{0}` where `Pet` = '{1}'", Properties.Settings.Default.PetBoardFriendsDomain, this._petIdString)
                };
                SelectResponse selectResponse = _simpleDBClient.Select(selectRequest);
                LikesCount.Text = selectResponse.Items.Count().ToString();
            }
        }