Exemplo n.º 1
0
        protected void calRent_DayRender(object sender, DayRenderEventArgs e)
        {
            if (Request.QueryString["id"] != null)
            {
                //only get dates once per calendar build-up
                if (availableDates == null)
                {
                    try
                    {
                        DvdInfo thisDVD = new DvdInfoService().getByID(Request.QueryString["id"].ToString());        //Throws NoRecordException
                        availableDates = new AvailabilityModel().getAvailabilities(thisDVD, DateTime.Now);           //Throws NoRecordException
                    }
                    catch (NoRecordException)
                    {
                    }
                }

                //movie can be reserved between today and 14 days from now
                if (availableDates.Contains(e.Day.Date))
                {
                    e.Day.IsSelectable = true;
                    e.Cell.BackColor   = System.Drawing.Color.LightGreen;
                }
                else
                {
                    e.Day.IsSelectable = false;
                    e.Cell.BackColor   = System.Drawing.Color.LightGray;
                }
            }
        }
        protected void btnBuy_Click(object sender, EventArgs e)
        {
            //add item to cart
            String dvd_info_id = id;

            Customer user = (Customer)Session["user"];

            if (user != null)
            {
                try
                {
                    DvdInfo thisDvd = new DvdInfoService().getByID(dvd_info_id.ToString());          //Throws NoRecordException
                    if (new ShoppingCartService().addByCustomerAndDvd(user, thisDvd))
                    {
                        //success
                    }
                }
                catch (NoRecordException)
                {
                }
            }
            else
            {
                string script = "alert(\"Please log in to buy this item.\");";
                ScriptManager.RegisterStartupScript(this, GetType(), "ServerControlScript", script, true);
            }
        }
Exemplo n.º 3
0
        /*Shows the availabe rent period buttons.*/
        protected void calRent_SelectionChanged(object sender, EventArgs e)
        {
            if (Request.QueryString["id"] != null)
            {
                try
                {
                    DvdInfo dvdInfo = new DvdInfoService().getByID(Request.QueryString["id"].ToString());            //Throws NoRecordException

                    //get all dvd copies that are available on that date:
                    int daysAvailable = new AvailabilityModel().getDaysAvailableFromDate(dvdInfo, calRent.SelectedDate);    //Throws NoRecordException

                    if (daysAvailable >= 1)
                    {
                        btnRent1.Visible = true;
                    }
                    if (daysAvailable >= 3)
                    {
                        btnRent3.Visible = true;
                    }
                    if (daysAvailable >= 7)
                    {
                        btnRent7.Visible = true;
                    }
                }
                catch (NoRecordException)
                {
                }
            }
        }
Exemplo n.º 4
0
        private void setupRelatedDvds(String id)
        {
            try
            {
                pnlRelatedDvds.Visible = true;
                List <DvdInfo> list = new DvdInfoService().getRelatedDvds(id, 4);            //Throws NoRecordException

                linkRelated.NavigateUrl = "~/Catalog.aspx?related=" + id;
                foreach (DvdInfo d in list)
                {
                    dvdInfoUserControl dvdInfoControl = (dvdInfoUserControl)Page.LoadControl("dvdInfoUserControl.ascx");
                    dvdInfoControl.id = d.dvd_info_id;
                    foreach (KeyValuePair <int, String> k in d.media)
                    {
                        if (k.Key == 1)
                        {
                            dvdInfoControl.imageUrl = k.Value;
                        }
                    }
                    dvdInfoControl.title      = d.name;
                    dvdInfoControl.buy_price  = d.buy_price;
                    dvdInfoControl.rent_price = d.rent_price;

                    relatedDvds.Controls.Add(dvdInfoControl);
                }
            }
            catch (NoRecordException)
            {
                pnlRelatedDvds.Visible = false;
            }
        }
Exemplo n.º 5
0
        /**Adds the buy dvd to the user's shopping cart*/
        protected void btnBuy_Click(object sender, EventArgs e)
        {
            Customer customer = (Customer)Session["user"];

            if (customer != null)
            {
                try
                {
                    DvdInfo dvdInfo = new DvdInfoService().getByID(Request.QueryString["id"]);           //Throws NoRecordException
                    if (new ShoppingCartService().addByCustomerAndDvd(customer, dvdInfo))
                    {
                        //success
                        lblBuyStatus.Text      = "Item added to cart.";
                        lblBuyStatus.ForeColor = System.Drawing.Color.Green;
                    }
                }
                catch (NoRecordException)
                {
                }
            }
            else
            {
                string script = "alert(\"Please log in to buy this item.\");";
                ScriptManager.RegisterStartupScript(this, GetType(), "ServerControlScript", script, true);
            }
        }
Exemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Hide rent buttons until the user selects a start date
            lblItemAdded.Text = "";
            btnRent1.Visible  = false;
            btnRent3.Visible  = false;
            btnRent7.Visible  = false;

            String dvd_info_id = Request.QueryString["id"];

            if (dvd_info_id != null)
            {
                setupDvdInfo(dvd_info_id);
                setupRelatedDvds(dvd_info_id);

                Customer user = (Customer)Session["user"];

                if (user != null)
                {
                    try
                    {
                        DvdInfo dvdInfo = new DvdInfoService().getByID(dvd_info_id);        //Throws NoRecordException
                        new PageVisitsModel().incrementPageVisits(user, dvdInfo);           //Throws NoRecordException
                    }
                    catch (NoRecordException)
                    {
                    }
                }
            }
        }
        private void setupSpotlight()
        {
            try
            {
                List <DvdInfo> dvdsWithBanner = new DvdInfoService().getAllWithBanner();               //Throws NoRecordException

                //selects a random dvd with a banner image to display as spotlight, could be set using an admin module
                if (dvdsWithBanner.Count > 0)
                {
                    Random  rnd          = new Random();
                    DvdInfo spotlightDvd = dvdsWithBanner[rnd.Next(dvdsWithBanner.Count)];

                    anchorSpotlight.HRef = "Detail.aspx?id=" + spotlightDvd.dvd_info_id;
                    foreach (KeyValuePair <int, String> k in spotlightDvd.media)
                    {
                        if (k.Key == 4)
                        {
                            imgSpotlight.Src = k.Value;
                        }
                    }
                }
            }
            catch (NoRecordException)
            {
            }
        }
 private void setupMostPopular()
 {
     try
     {
         divPopular.Visible = true;
         List <DvdInfo> dvdList = new DvdInfoService().getMostPopularDvds(4);         //Throws NoRecordException
         addTilesToRow(dvdList, mostPopular);
     }
     catch (NoRecordException)
     {
         divPopular.Visible = false;
     }
 }
 private void setupNewReleases()
 {
     try
     {
         divRecent.Visible = true;
         List <DvdInfo> dvdList = new DvdInfoService().getLatestDvds(4);              //Throws NoRecordException()
         addTilesToRow(dvdList, newReleases);
     }
     catch (NoRecordException)
     {
         divRecent.Visible = false;
     }
 }
        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.º 11
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)
            {
            }
        }
Exemplo n.º 12
0
        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.";
            }
        }