public ActionResult TopRecommendations()
        {
            var results = from x in db.clothes_dryer
                          select x;
            int    pagesize = 9, pageindex = 1;
            CdList temp = new CdList();

            results = results.Where(x => x.New_Star >= 5).OrderBy(x => Guid.NewGuid()).Take(9);
            var list = results.ToList();

            temp.Clothes_dryers = list.ToPagedList(pageindex, pagesize);
            BreadCrumb.Clear();
            BreadCrumb.Add(Url.Action("Index", "Home"), "Home");
            BreadCrumb.Add(Url.Action("AppliancesType", "Home"), "Save Energy");
            BreadCrumb.Add(Url.Action("Index", "clothes_dryer"), "Clothes Dryer");
            BreadCrumb.Add("", "Top Recommendations");
            List <SelectListItem> Ratings_level = new List <SelectListItem>();

            Ratings_level.Add(new SelectListItem()
            {
                Text = "All Ratings", Value = "-1"
            });
            Ratings_level.Add(new SelectListItem()
            {
                Text = "1 Star", Value = "1"
            });
            Ratings_level.Add(new SelectListItem()
            {
                Text = "2 Star", Value = "2"
            });
            Ratings_level.Add(new SelectListItem()
            {
                Text = "3 Star", Value = "3"
            });
            Ratings_level.Add(new SelectListItem()
            {
                Text = "4 Star", Value = "4"
            });
            Ratings_level.Add(new SelectListItem()
            {
                Text = "5 Star", Value = "5"
            });
            this.ViewBag.Ratings = new SelectList(Ratings_level, "Value", "Text");
            return(View(temp));
        }
        public ActionResult Index(int?page, string searchString, string currentFilter, string Ratings, string currentRatings)
        {
            decimal rating;

            if (!String.IsNullOrEmpty(Ratings))
            {
                rating = decimal.Parse(Ratings);
            }
            else
            if (!String.IsNullOrEmpty(currentRatings))
            {
                rating = decimal.Parse(currentRatings);
            }
            else
            {
                rating = -1;
            }
            var results = from x in db.clothes_dryer
                          select x;
            int    pagesize = 9, pageindex = 1;
            CdList temp = new CdList();

            if (searchString != null || Ratings != null)
            {
                page = 1;
            }
            else
            {
                Ratings      = currentRatings;
                searchString = currentFilter;
            }

            // Showing data based on the search query string and the star rating selected from the dropdown.

            ViewData["CurrentRatings"] = Ratings;
            ViewData["CurrentFilter"]  = searchString;
            if (!String.IsNullOrEmpty(searchString) && rating != -1)
            {
                results = results.Where(s => s.Brand.Contains(searchString) && s.New_Star < (rating + 1) && s.New_Star >= rating);
            }
            else
            if (!String.IsNullOrEmpty(searchString) && rating == -1)
            {
                results = results.Where(s => s.Brand.Contains(searchString));
            }
            else
            if (String.IsNullOrEmpty(searchString) && rating != -1)
            {
                results = results.Where(s => s.New_Star < (rating + 1) && s.New_Star >= rating);
            }
            else
            {
                results = results.Where(x => x.Type_Id == 1);
            }

            pageindex = page.HasValue ? Convert.ToInt32(page) : 1;
            var list = results.ToList();

            temp.Clothes_dryers = list.ToPagedList(pageindex, pagesize);

            // showing the navigation map using the bread crumbs.

            BreadCrumb.Clear();
            BreadCrumb.Add(Url.Action("Index", "Home"), "Home");
            BreadCrumb.Add(Url.Action("AppliancesType", "Home"), "Save Energy");
            BreadCrumb.Add("", "Clothes Dryers");

            //adding the values in dropdown list

            List <SelectListItem> Ratings_level = new List <SelectListItem>();

            Ratings_level.Add(new SelectListItem()
            {
                Text = "All Ratings", Value = "-1"
            });
            Ratings_level.Add(new SelectListItem()
            {
                Text = "1 Star", Value = "1"
            });
            Ratings_level.Add(new SelectListItem()
            {
                Text = "2 Star", Value = "2"
            });
            Ratings_level.Add(new SelectListItem()
            {
                Text = "3 Star", Value = "3"
            });
            Ratings_level.Add(new SelectListItem()
            {
                Text = "4 Star", Value = "4"
            });
            Ratings_level.Add(new SelectListItem()
            {
                Text = "5 Star", Value = "5"
            });
            this.ViewBag.Ratings = new SelectList(Ratings_level, "Value", "Text", currentRatings);
            return(View(temp));
        }
Ejemplo n.º 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Hashtable books  = new Hashtable();
            Hashtable movies = new Hashtable();
            Hashtable CDs    = new Hashtable();
            Hashtable others = new Hashtable();

            books.Add("Harry Potter i Kamień Filozoficzny - 24.99", 24.99);
            books.Add("Harry Potter i Komnata Tajemnic - 24.99", 24.99);
            books.Add("Harry Potter i Więzień Azkabanu - 24.99", 24.99);
            books.Add("Harry Potter i Czara Ognia - 24.99", 24.99);
            books.Add("Harry Potter i Zakon Feniksa - 24.99", 24.99);
            books.Add("Harry Potter i Książe Półkrwi - 24.99", 24.99);
            books.Add("Harry Potter i Insygnia Śmierci - 24.99", 24.99);

            movies.Add("Star Wars Episode I The Phantom Menace - 34.99", 34.99);
            movies.Add("Star Wars Episode II Attack of the Clones - 34.99", 34.99);
            movies.Add("Star Wars Episode III Revenge of the Sith - 34.99", 34.99);
            movies.Add("Star Wars Episode IV A New Hope - 34.99", 34.99);
            movies.Add("Star Wars Episode V The Empire Strikes Back - 34.99", 34.99);
            movies.Add("Star Wars Episode VI Return of the Jedi - 34.99", 34.99);
            movies.Add("Star Wars Episode VII The Force Awakens - 34.99", 34.99);
            movies.Add("Star Wars Episode VIII The Last Jedi - 34.99", 34.99);

            CDs.Add("Michael Jackson - Thriller - 40.00", 40.00);
            CDs.Add("Eagles - Their Greatest Hits - 40.00", 40.00);
            CDs.Add("AC/DC - Back in Black - 40.00", 40.00);
            CDs.Add("Pink Floyd - The Dark Side of the Moon - 40.00", 40.00);
            CDs.Add("Whitney Houston - The Bodygourd - 40.00", 40.00);

            others.Add("Zeszyt A5 - 2.49", 2.49);
            others.Add("Zeszyt A4 - 3.99", 3.99);
            others.Add("Długopis - 1.99", 1.99);
            others.Add("Ołówek - 1.49", 1.49);

            bookList.DataSource     = books;
            bookList.DataValueField = "Value";
            bookList.DataTextField  = "Key";
            bookList.DataBind();

            movieList.DataSource     = movies;
            movieList.DataValueField = "Value";
            movieList.DataTextField  = "Key";
            movieList.DataBind();

            CdList.DataSource     = CDs;
            CdList.DataValueField = "Value";
            CdList.DataTextField  = "Key";
            CdList.DataBind();

            otherList.DataSource     = others;
            otherList.DataValueField = "Value";
            otherList.DataTextField  = "Key";
            otherList.DataBind();
        }

        switch (RadioButtonList1.SelectedValue)
        {
        case "Książki":
            bookList.Visible  = true;
            movieList.Visible = false;
            CdList.Visible    = false;
            otherList.Visible = false;
            break;

        case "Filmy":
            movieList.Visible = true;
            bookList.Visible  = false;
            CdList.Visible    = false;
            otherList.Visible = false;
            break;

        case "Płyty":
            CdList.Visible    = true;
            movieList.Visible = false;
            bookList.Visible  = false;
            otherList.Visible = false;
            break;

        case "Inne":
            otherList.Visible = true;
            CdList.Visible    = false;
            movieList.Visible = false;
            bookList.Visible  = false;
            break;
        }

        selectedCategory.Text = RadioButtonList1.SelectedValue + ":";

        counter.Text = "Wybranych produktów: " + Session.Count;
    }