Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string adID     = Request.QueryString.Get("ad");
            bool   isnumber = int.TryParse(adID, out adnum);

            if (isnumber)
            {
                AdService.AdCRUDClient adService = new AdService.AdCRUDClient();
                adService.Open();
                this.adDetails = adService.getAdDetails(adID);
                adService.incViewCount(Convert.ToInt32(adID));
                adService.Close();
                if (this.adDetails != null)
                {
                    //--------------TITLE
                    lblGameTitle.InnerHtml = (string)adDetails[1];
                    Title = "twoGAMES: " + (string)adDetails[1];

                    //--------------PRICE
                    lblGamePrice.InnerHtml = "Price: R" + (string)adDetails[6];

                    //--------------NEGOTIABLE
                    if (Convert.ToBoolean(adDetails[7]))
                    {
                        lblGamePrice.InnerHtml += " Negotiable";
                    }

                    //--------------USERNAME + PREMIUM ICON
                    UserService.UserCRUDClient userService = new UserService.UserCRUDClient();
                    userService.Open();
                    string  username    = userService.getUsername(Convert.ToInt32((string)adDetails[13]));
                    Boolean premiumUser = Convert.ToBoolean(userService.isUserPrem(Convert.ToInt32((string)adDetails[13])));
                    userService.Close();

                    editButtonSpan.InnerHtml = "Posted By: " + username;
                    if (premiumUser)
                    {
                        editButtonSpan.InnerHtml += " <i class='material-icons tooltipped' data-position='right' data-tooltip='Premium Member'>star</i>";
                    }

                    //--------------ADMIN MOD BUTTONS
                    //editButtonSpan.InnerHtml = "";
                    if (Session["User"] != null)
                    {
                        if (((UserData)Session["User"]).isAdmin() == 1 || ((UserData)Session["User"]).isMod() == 1)
                        {
                            btnReportAd.Visible = false;
                            if (Convert.ToBoolean((string)adDetails[14]))
                            {
                                btnUnflagAdAdminMod.Visible = true;
                            }
                            else
                            {
                                btnFlagAdAdminMod.Visible = true;
                            }
                            editButtonSpan.InnerHtml += " <a class='btn right waves-effect waves-light orange lighten-2' href='EditAdPage.aspx?ad=" + Request.QueryString.Get("ad") + "'>Edit</a> ";
                        }
                    }

                    //--------------IMAGES
                    if (!((string)adDetails[9]).Equals("NOPIC"))
                    {
                        imgPic1.Src = "data:image/jpeg;base64," + (string)adDetails[9];
                    }
                    else
                    {
                        imgPic1.Visible = false;
                    }
                    if (!((string)adDetails[10]).Equals("NOPIC"))
                    {
                        imgPic2.Src = "data:image/jpeg;base64," + (string)adDetails[10];
                    }
                    else
                    {
                        imgPic2.Visible = false;
                    }
                    if (!((string)adDetails[11]).Equals("NOPIC"))
                    {
                        imgPic3.Src = "data:image/jpeg;base64," + (string)adDetails[11];
                    }
                    else
                    {
                        imgPic3.Visible = false;
                    }

                    //--------------PLATFORM
                    lblGamePlatform.InnerHtml = "Platform: " + (string)adDetails[2];

                    //--------------DESCRIPTION
                    txtGameDescription.Value = (string)adDetails[4];

                    //--------------LOCATION
                    txtGameLocation.Value = (string)adDetails[5];
                    String mapString = (string)adDetails[5];
                    mapString = mapString.Replace(" ", "+");
                    adMap.Src = "https://www.google.com/maps/embed/v1/place?key=AIzaSyB7eq5IZFtbXZitO0yI53upIROFqC5RBcY&q=" + mapString;

                    //--------------YOUTUBE SOURCE
                    adYoutubeFrame.Src = "https://www.youtube.com/embed?listType=search&list=" + (string)adDetails[1] + " ign review?theme=light&color=white";

                    //--------------CELL NUMBER
                    if (Convert.ToBoolean(adDetails[8]))
                    {
                        txtCellNumber.Value = (string)adDetails[16];
                    }
                    else
                    {
                        sellerCellNumberDiv.InnerHtml = "";
                    }
                }
            }
            else
            {
                Response.Redirect("Index.aspx");
            }
        }