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; }
private void setDvdTiles(String search) { String type = Request.QueryString["type"]; dvdInfoService = new DvdInfoService(); List <DvdInfo> dvdContent = null; String searchtext = ""; if (Request.QueryString["search"] != null) { searchtext = Request.QueryString["search"]; } String labelText = ""; String genre_id = Request.QueryString["genre"]; String category_id = Request.QueryString["cat"]; String year = Request.QueryString["year"]; String director = Request.QueryString["director"]; String actor = Request.QueryString["actor"]; String related = Request.QueryString["related"]; try { if (type != null) { switch (type) { case "popular": labelText = "Most popular DVDs"; dvdContent = new DvdInfoService().getMostPopularDvds(16); //Throws NoRecordException break; case "recommended": if (Session["user"] != null) { labelText = "Recommended for you"; dvdContent = new RecommendationsModel().getRecommendations(((Customer)Session["user"]), 16); //Throws NoRecordException } break; case "recent": labelText = "Recent releases"; dvdContent = new DvdInfoService().getLatestDvds(16); //Throws NoRecordException break; } } else if (genre_id != null) { labelText = new GenreService().getByID(genre_id).name + " DVDs"; //Throws NoRecordException dvdContent = dvdInfoService.searchDvdWithTextAndGenre(searchtext, genre_id); //Throws NoRecordException } else if (category_id != null) { labelText = new CategoryService().getByID(category_id).name + " DVDs"; //Throws NoRecordException dvdContent = dvdInfoService.searchDvdWithTextAndCategory(searchtext, category_id); //Throws NoRecordException } else if (year != null) { labelText = "Dvd's from " + year; dvdContent = dvdInfoService.searchDvdFromYear(year); //Throws NoRecordException } else if (director != null) { labelText = "Dvd's from " + director; dvdContent = dvdInfoService.searchDvdFromDirector(director); //Throws NoRecordException } else if (actor != null) { labelText = "Dvd's with " + actor; dvdContent = dvdInfoService.searchDvdWithActor(actor); //Throws NoRecordException } else if (related != null) { labelText = "Related dvds for " + dvdInfoService.getByID(related).name; //Throws NoRecordException dvdContent = dvdInfoService.getRelatedDvds(related, 16); //Throws NoRecordException } else { labelText = "Catalog"; dvdContent = dvdInfoService.searchDvdWithText(searchtext); //Throws NoRecordException } //set header text if (!searchtext.Equals("")) { labelText += " matching '" + searchtext + "'"; } foreach (DvdInfo d in dvdContent) { if (search != null && checkMatches(d, search)) { dvdInfoUserControl dvdInfo = (dvdInfoUserControl)Page.LoadControl("dvdInfoUserControl.ascx"); dvdInfo.ChoiceComplete += new dvdInfoUserControl.delChoiceComplete(dvdInfo_ChoiceComplete); dvdInfo.id = d.dvd_info_id; foreach (KeyValuePair <int, String> k in d.media) { if (k.Key == 1) { dvdInfo.imageUrl = k.Value; } } dvdInfo.title = d.name; dvdInfo.buy_price = d.buy_price; dvdInfo.rent_price = d.rent_price; catalogContent.Controls.Add(dvdInfo); } else if (search == null) { dvdInfoUserControl dvdInfo = (dvdInfoUserControl)Page.LoadControl("dvdInfoUserControl.ascx"); dvdInfo.ChoiceComplete += new dvdInfoUserControl.delChoiceComplete(dvdInfo_ChoiceComplete); dvdInfo.id = d.dvd_info_id; foreach (KeyValuePair <int, String> k in d.media) { if (k.Key == 1) { dvdInfo.imageUrl = k.Value; } } dvdInfo.title = d.name; dvdInfo.buy_price = d.buy_price; dvdInfo.rent_price = d.rent_price; catalogContent.Controls.Add(dvdInfo); } } lblHeader.Text = labelText; } catch (NoRecordException) { lblHeader.Text = labelText; lblStatus.Text = "Could not find any results matching your criteria."; } }