Exemplo n.º 1
0
        private float setPriceInRightCurrency(float price, String currency)
        {
            wsCurrencyWebService.CurrencyWebService currencyWebService = new wsCurrencyWebService.CurrencyWebService();

            if (currency.Equals("€"))
            {
                return(price);
            }
            return((float)currencyWebService.convert(price, "usd"));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            String currency = "€";

            wsCurrencyWebService.CurrencyWebService currencyWebService = new wsCurrencyWebService.CurrencyWebService();

            dvdInfoLink.NavigateUrl  = "~/detail.aspx?id=" + id;
            dvdInfoLink2.NavigateUrl = dvdInfoLink.NavigateUrl;
            imgDvdCover.ImageUrl     = imageUrl;
            if (title.Length <= 40)
            {
                lblTitle.Text = title;
            }
            else
            {
                lblTitle.Text = title.Substring(0, 28) + "...";
            }


            if (Request.QueryString["currency"] == null)
            {
                if (CookieUtil.CookieExists("currency"))
                {
                    switch (CookieUtil.GetCookieValue("currency"))
                    {
                    case "usd":
                        currency   = "$";
                        buy_price  = (float)currencyWebService.convert(buy_price, "usd");
                        rent_price = (float)currencyWebService.convert(rent_price, "usd");
                        break;
                    }
                }
            }
            else
            {
                switch (Request.QueryString["currency"])
                {
                case "usd":
                    currency   = "$";
                    buy_price  = (float)currencyWebService.convert(buy_price, "usd");
                    rent_price = (float)currencyWebService.convert(rent_price, "usd");
                    break;
                }
            }

            //set buy button color and text
            if (AvailabilityModel.isAvailableForBuying(Convert.ToString(id)))
            {
                btnBuyB.Attributes.Add("Class", "btn btn-success price-box");
            }
            else
            {
                btnBuyB.Attributes.Add("Class", "btn btn-warning price-box");
            }
            btnBuyB.InnerText = "Buy " + currency + " " + buy_price;

            //set rent button properties and text
            btnRentB.Attributes.Add("CommandArgument", id);

            DvdInfoService dvdbll = new DvdInfoService();

            try
            {
                DvdInfo         thisDVD = dvdbll.getByID(Convert.ToString(id));                             //Throws NoRecordExample
                List <DateTime> dates   = new AvailabilityModel().getAvailabilities(thisDVD, DateTime.Now); //Throws NoRecordException


                if (dates.Count >= 14)
                {
                    //fully available, green button
                    btnRentB.Attributes.Add("Class", "btn btn-success price-box");
                }
                else if (dates.Count > 0)
                {
                    //available on some days, orange button
                    btnRentB.Attributes.Add("Class", "btn btn-warning price-box");
                }
                else
                {
                    //not available at all, red button
                    btnRentB.Attributes.Add("Class", "btn btn-danger price-box");
                }
            }
            catch (NoRecordException)
            {
            }

            btnRentB.InnerText = "Rent " + currency + " " + rent_price;
        }
Exemplo n.º 3
0
        private void setupDvdInfo(String id)
        {
            try
            {
                wsCurrencyWebService.CurrencyWebService currencyWebService = new wsCurrencyWebService.CurrencyWebService();
                String currency = "€";

                DvdInfo dvdInfo = new DvdInfoService().getByID(id.ToString());           //Throws NoRecordException

                lblTitle.Text        = dvdInfo.name + " ";
                linkYear.Text        = "(" + dvdInfo.year + ")";
                linkYear.NavigateUrl = "~/Catalog.aspx?year=" + dvdInfo.year;

                linkDirector.Text        = dvdInfo.author;
                linkDirector.NavigateUrl = "~/Catalog.aspx?director=" + dvdInfo.author;

                if (!dvdInfo.actors[0].Equals("")) //even dvd's without actors contain 1 empty string element
                {
                    foreach (String a in dvdInfo.actors)
                    {
                        HyperLink actor = new HyperLink();
                        actor.Text        = a;
                        actor.NavigateUrl = "~/Catalog.aspx?actor=" + a;
                        actorLinks.Controls.Add(actor);
                        Label l = new Label();
                        l.Text = ", ";
                        actorLinks.Controls.Add(l);
                    }
                    int i = actorLinks.Controls.Count;
                    actorLinks.Controls.RemoveAt(i - 1);
                    actorLinks.Controls.Add(new LiteralControl("<br />"));
                }
                else
                {
                    lblActors.Visible = false;
                }

                if (!dvdInfo.duration.Equals(""))
                {
                    lblDuration.Text = dvdInfo.duration + " min";
                }
                else
                {
                    spanRuntime.Visible = false;
                }

                foreach (Genre g in dvdInfo.genres)
                {
                    HyperLink genre = new HyperLink();
                    genre.Text        = g.name;
                    genre.NavigateUrl = "~/Catalog.aspx?genre=" + g.genre_id;

                    genreLinks.Controls.Add(genre);
                    Label l = new Label();
                    l.Text = ", ";
                    genreLinks.Controls.Add(l);
                }
                int j = genreLinks.Controls.Count;
                if (j > 0)
                {
                    genreLinks.Controls.RemoveAt(j - 1);
                }

                lblPlot.Text = dvdInfo.descripion;

                if (Request.QueryString["currency"] == null)
                {
                    if (CookieUtil.CookieExists("currency"))
                    {
                        switch (CookieUtil.GetCookieValue("currency"))
                        {
                        case "usd":
                            currency           = "$";
                            dvdInfo.buy_price  = (float)currencyWebService.convert(dvdInfo.buy_price, "usd");
                            dvdInfo.rent_price = (float)currencyWebService.convert(dvdInfo.rent_price, "usd");
                            break;
                        }
                    }
                }
                else
                {
                    switch (Request.QueryString["currency"])
                    {
                    case "usd":
                        currency           = "$";
                        dvdInfo.buy_price  = (float)currencyWebService.convert(dvdInfo.buy_price, "usd");
                        dvdInfo.rent_price = (float)currencyWebService.convert(dvdInfo.rent_price, "usd");
                        break;
                    }
                }

                if (AvailabilityModel.isAvailableForBuying(Request.QueryString["id"]))
                {
                    lblBuyStatus.Text = "";
                    btnBuyB.Attributes.Add("Class", "btn btn-success");
                }
                else
                {
                    lblBuyStatus.Text = "Item currently out of stock!";
                    btnBuyB.Attributes.Add("Class", "btn btn-warning");
                }

                btnBuyB.InnerText = "Buy " + currency + " " + dvdInfo.buy_price.ToString();
                btnRent1.Text     = "Rent 1 day " + currency + " " + dvdInfo.rent_price.ToString();
                btnRent3.Text     = "Rent 3 days " + currency + " " + (dvdInfo.rent_price * 3).ToString();
                btnRent7.Text     = "Rent 7 days " + currency + " " + (dvdInfo.rent_price * 7).ToString();

                foreach (KeyValuePair <int, String> k in dvdInfo.media)
                {
                    if (k.Key == 1)
                    {
                        imgDvdCoverFocus.ImageUrl = k.Value;
                    }

                    else if (k.Key == 2)
                    {
                        HtmlGenericControl div = new HtmlGenericControl("div");
                        div.Attributes["class"] = "col-xs-3 col-sm-3 col-md-3 col-lg-3 DocumentItem";

                        Image img = new Image();
                        img.ImageUrl = k.Value;
                        div.Controls.Add(img);

                        scrollrow.Controls.Add(div);
                    }
                    else if (k.Key == 3)
                    {
                        HtmlGenericControl div = new HtmlGenericControl("div");
                        div.Attributes["class"] = "col-xs-3 col-sm-3 col-md-3 col-lg-3 DocumentItem";
                        Literal youtube = new Literal();
                        youtube.Text = GetYouTubeScript(k.Value);
                        div.Controls.Add(youtube);
                        scrollrow.Controls.Add(div);
                    }
                }
            }
            catch (NoRecordException)
            {
            }
        }