Example #1
0
        private void TotalSoldPerGame()
        {
            var              db                = new AlchemyLinkDataContext();
            List <int>       gamesSold         = new List <int>();
            List <int>       listOfUniqueGames = new List <int>();
            List <GameCount> totalPerGame      = new List <GameCount>();

            dynamic copies = from o in db.Order_Products
                             select o;

            foreach (Order_Product order in copies)
            {
                gamesSold.Add(order.ProductID);
            }

            listOfUniqueGames = gamesSold.Distinct().ToList();

            for (int i = 0; i < listOfUniqueGames.Count; i++)
            {
                int count = 0;
                foreach (int id in gamesSold)
                {
                    if (id.Equals(listOfUniqueGames.ElementAt(i)))
                    {
                        count++;
                    }
                }

                GameCount game = new GameCount();
                game.setGameCount(count);
                game.setGameID(listOfUniqueGames.ElementAt(i));
                totalPerGame.Add(game);
            }

            DataTable table = makeTable("Total Copies Sold");

            for (int i = 0; i < totalPerGame.Count; i++)
            {
                var     prod = totalPerGame.ElementAt(i).GetProduct();
                DataRow row  = table.NewRow();
                row["ID"]         = prod.Id;
                row["GameName"]   = prod.Name;
                row["CopiesSold"] = totalPerGame.ElementAt(i).getGameCount();
                table.Rows.Add(row);
            }

            CopiesPerGame.DataSource = table;
            //CopiesPerGame.DataSource = copies;
            CopiesPerGame.DataBind();
            //totalPerGame now has the total copies sold per game with its corrosponding game ID
            //Series series = MonthUsers.Series["DaysOfMonth"];
            //for(int i = 0; i < totalPerGame.Count; i++)
            //{
            //    var prod = totalPerGame.ElementAt(i).GetProduct();
            //    int num = totalPerGame.ElementAt(i).getGameCount();
            //    series.Points.AddXY(prod.Name, num);
            //}
        }
        private void TotalSoldPerGame()
        {
            var              db                = new AlchemyLinkDataContext();
            List <int>       gamesSold         = new List <int>();
            List <int>       listOfUniqueGames = new List <int>();
            List <GameCount> totalPerGame      = new List <GameCount>();

            dynamic copies = from o in db.Order_Products
                             select o;

            foreach (Order_Product order in copies)
            {
                gamesSold.Add(order.ProductID);
            }

            listOfUniqueGames = gamesSold.Distinct().ToList();

            for (int i = 0; i < listOfUniqueGames.Count; i++)
            {
                int count = 0;
                foreach (int id in gamesSold)
                {
                    if (id.Equals(listOfUniqueGames.ElementAt(i)))
                    {
                        count++;
                    }
                }

                GameCount game = new GameCount();
                game.setGameCount(count);
                game.setGameID(listOfUniqueGames.ElementAt(i));
                totalPerGame.Add(game);
            }

            //totalPerGame now has the total copies sold per game with its corrosponding game ID
        }
Example #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var pageType = Request.QueryString["ID"];
            var gametype = gameType.Value;
            var sortby   = SortBy.Value;
            var genre    = GameGenre.Value;

            switch (pageType)
            {
            case "PC":
                Session["currentPage"] = "PC";
                break;

            case "PS":
                Session["currentPage"] = "PS";
                break;

            case "Xbox":
                Session["currentPage"] = "xbox";
                break;

            case "Nintendo":
                Session["currentPage"] = "nintendo";
                break;
            }

            StringBuilder display = new StringBuilder();

            display.Clear();

            var db = new AlchemyLinkDataContext();

            dynamic games = from g in db.Products
                            where g.Platfrom.Equals(pageType) && g.Type.Equals(gametype)
                            select g;

            dynamic orders = from o in db.Order_Products
                             select o;

            List <int>       popGamesCount = new List <int>();
            List <int>       popGames      = new List <int>();
            List <GameCount> popGameRating = new List <GameCount>();

            foreach (Order_Product o in orders)
            {
                popGamesCount.Add(o.ProductID);
            }

            popGames = popGamesCount.Distinct().ToList();

            for (int i = 0; i < popGames.Count; i++)
            {
                GameCount newGame = new GameCount();
                newGame.setGameID(popGames.ElementAt(i));
                newGame.setGameCount(0);
                popGameRating.Add(newGame);
            }

            for (int i = 0; i < popGameRating.Count; i++)
            {
                foreach (int id in popGamesCount)
                {
                    if (popGameRating.ElementAt(i).getGameID().Equals(id))
                    {
                        int count = popGameRating.ElementAt(i).getGameCount();
                        count++;
                        popGameRating.ElementAt(i).setGameCount(count);
                    }
                }
            }

            popGameRating = popGameRating.OrderByDescending(o => o.getGameCount()).ToList();

            if (genre.Equals("none"))
            {
                if (sortby.Equals("Pop"))
                {
                    List <int> rejectGames   = new List <int>();
                    List <int> selectedGames = new List <int>();
                    for (int i = 0; i < popGameRating.Count; i++)
                    {
                        Product prodR = popGameRating.ElementAt(i).GetProduct();

                        foreach (Product prod in games)
                        {
                            if (prodR.Id.Equals(prod.Id))
                            {
                                if (prod.StockLevels > 0)
                                {
                                    selectedGames.Add(prod.Id);
                                    display.Append("<div class=\"product\">" + Environment.NewLine);
                                    display.Append("<div class=\"inner-product\">" + Environment.NewLine);
                                    display.Append("<div class=\"figure-image\">" + Environment.NewLine);
                                    display.Append("<a href =\"single.aspx?ID=" + prod.Id + "\">" + Environment.NewLine);
                                    display.Append("<img src=\"" + prod.ImageLink + "\"></a>" + Environment.NewLine);
                                    display.Append("</div>" + Environment.NewLine);
                                    display.Append("<h3 class=\"product-title\"><a href=\"Single.aspx?ID=" + prod.Id + "\">" + prod.Name + "</a></h3>" + Environment.NewLine);
                                    display.Append("<small class=\"price\">" + String.Format("{0:C2}", prod.Price) + "</small>" + Environment.NewLine);
                                    display.Append("<br />");
                                    display.Append("</div>" + Environment.NewLine);
                                    display.Append("</div>" + Environment.NewLine);
                                }
                            }
                        }
                    }

                    foreach (Product p in games)
                    {
                        Boolean found = false;
                        foreach (int i in selectedGames)
                        {
                            if (p.Id.Equals(i))
                            {
                                found = true;
                            }
                        }

                        if (!found)
                        {
                            rejectGames.Add(p.Id);
                        }
                    }

                    for (int i = 0; i < rejectGames.Count; i++)
                    {
                        Product prod = (from p in db.Products
                                        where p.Id.Equals(rejectGames.ElementAt(i))
                                        select p).FirstOrDefault();

                        if (prod.StockLevels > 0)
                        {
                            display.Append("<div class=\"product\">" + Environment.NewLine);
                            display.Append("<div class=\"inner-product\">" + Environment.NewLine);
                            display.Append("<div class=\"figure-image\">" + Environment.NewLine);
                            display.Append("<a href =\"single.aspx?ID=" + prod.Id + "\">" + Environment.NewLine);
                            display.Append("<img src=\"" + prod.ImageLink + "\"></a>" + Environment.NewLine);
                            display.Append("</div>" + Environment.NewLine);
                            display.Append("<h3 class=\"product-title\"><a href=\"Single.aspx?ID=" + prod.Id + "\">" + prod.Name + "</a></h3>" + Environment.NewLine);
                            display.Append("<small class=\"price\">" + String.Format("{0:C2}", prod.Price) + "</small>" + Environment.NewLine);
                            display.Append("<br />");
                            display.Append("</div>" + Environment.NewLine);
                            display.Append("</div>" + Environment.NewLine);
                        }
                    }
                }
                else if (sortby.Equals("High"))
                {
                    dynamic game = from g in db.Products
                                   where g.Platfrom.Equals(pageType) && g.Type.Equals(gametype)
                                   orderby g.Price descending
                                   select g;

                    foreach (Product prod in game)
                    {
                        if (prod.StockLevels > 0)
                        {
                            display.Append("<div class=\"product\">" + Environment.NewLine);
                            display.Append("<div class=\"inner-product\">" + Environment.NewLine);
                            display.Append("<div class=\"figure-image\">" + Environment.NewLine);
                            display.Append("<a href =\"single.aspx?ID=" + prod.Id + "\">" + Environment.NewLine);
                            display.Append("<img src=\"" + prod.ImageLink + "\"></a>" + Environment.NewLine);
                            display.Append("</div>" + Environment.NewLine);
                            display.Append("<h3 class=\"product-title\"><a href=\"Single.aspx?ID=" + prod.Id + "\">" + prod.Name + "</a></h3>" + Environment.NewLine);
                            display.Append("<small class=\"price\">" + String.Format("{0:C2}", prod.Price) + "</small>" + Environment.NewLine);
                            display.Append("<br />");
                            display.Append("</div>" + Environment.NewLine);
                            display.Append("</div>" + Environment.NewLine);
                        }
                    }
                }
                else
                {
                    testMsg.InnerHtml = "Low reached";
                    dynamic game = from g in db.Products
                                   where g.Platfrom.Equals(pageType) && g.Type.Equals(gametype)
                                   orderby g.Price ascending
                                   select g;

                    foreach (Product prod in game)
                    {
                        if (prod.StockLevels > 0)
                        {
                            display.Append("<div class=\"product\">" + Environment.NewLine);
                            display.Append("<div class=\"inner-product\">" + Environment.NewLine);
                            display.Append("<div class=\"figure-image\">" + Environment.NewLine);
                            display.Append("<a href =\"single.aspx?ID=" + prod.Id + "\">" + Environment.NewLine);
                            display.Append("<img src=\"" + prod.ImageLink + "\"></a>" + Environment.NewLine);
                            display.Append("</div>" + Environment.NewLine);
                            display.Append("<h3 class=\"product-title\"><a href=\"Single.aspx?ID=" + prod.Id + "\">" + prod.Name + "</a></h3>" + Environment.NewLine);
                            display.Append("<small class=\"price\">" + String.Format("{0:C2}", prod.Price) + "</small>" + Environment.NewLine);
                            display.Append("<br />");
                            display.Append("</div>" + Environment.NewLine);
                            display.Append("</div>" + Environment.NewLine);
                        }
                    }
                }
            }
            else
            {
                if (SortBy.Equals("Pop"))
                {
                    List <int> rejectGames   = new List <int>();
                    List <int> selectedGames = new List <int>();
                    for (int i = 0; i < popGameRating.Count; i++)
                    {
                        Product prodR = popGameRating.ElementAt(i).GetProduct();

                        foreach (Product prod in games)
                        {
                            if (prodR.Id.Equals(prod.Id))
                            {
                                if ((prod.StockLevels > 0) && (prod.Genre.Equals(genre)))
                                {
                                    display.Append("<div class=\"product\">" + Environment.NewLine);
                                    display.Append("<div class=\"inner-product\">" + Environment.NewLine);
                                    display.Append("<div class=\"figure-image\">" + Environment.NewLine);
                                    display.Append("<a href =\"single.aspx?ID=" + prod.Id + "\">" + Environment.NewLine);
                                    display.Append("<img src=\"" + prod.ImageLink + "\"></a>" + Environment.NewLine);
                                    display.Append("</div>" + Environment.NewLine);
                                    display.Append("<h3 class=\"product-title\"><a href=\"Single.aspx?ID=" + prod.Id + "\">" + prod.Name + "</a></h3>" + Environment.NewLine);
                                    display.Append("<small class=\"price\">" + String.Format("{0:C2}", prod.Price) + "</small>" + Environment.NewLine);
                                    display.Append("<br />");
                                    display.Append("</div>" + Environment.NewLine);
                                    display.Append("</div>" + Environment.NewLine);
                                }
                            }
                        }
                    }

                    foreach (Product p in games)
                    {
                        Boolean found = false;
                        foreach (int i in selectedGames)
                        {
                            if (p.Id.Equals(i))
                            {
                                found = true;
                            }
                        }

                        if (!found)
                        {
                            rejectGames.Add(p.Id);
                        }
                    }

                    for (int i = 0; i < rejectGames.Count; i++)
                    {
                        Product prod = (from p in db.Products
                                        where p.Id.Equals(rejectGames.ElementAt(i))
                                        select p).FirstOrDefault();

                        if ((prod.StockLevels > 0) && (prod.Genre.Equals(genre)))
                        {
                            display.Append("<div class=\"product\">" + Environment.NewLine);
                            display.Append("<div class=\"inner-product\">" + Environment.NewLine);
                            display.Append("<div class=\"figure-image\">" + Environment.NewLine);
                            display.Append("<a href =\"single.aspx?ID=" + prod.Id + "\">" + Environment.NewLine);
                            display.Append("<img src=\"" + prod.ImageLink + "\"></a>" + Environment.NewLine);
                            display.Append("</div>" + Environment.NewLine);
                            display.Append("<h3 class=\"product-title\"><a href=\"Single.aspx?ID=" + prod.Id + "\">" + prod.Name + "</a></h3>" + Environment.NewLine);
                            display.Append("<small class=\"price\">" + String.Format("{0:C2}", prod.Price) + "</small>" + Environment.NewLine);
                            display.Append("<br />");
                            display.Append("</div>" + Environment.NewLine);
                            display.Append("</div>" + Environment.NewLine);
                        }
                    }
                }
                else if (sortby.Equals("High"))
                {
                    dynamic game = from g in db.Products
                                   where g.Platfrom.Equals(pageType) && g.Type.Equals(gametype)
                                   orderby g.Price descending
                                   select g;

                    foreach (Product prod in game)
                    {
                        if ((prod.StockLevels > 0) && (prod.Genre.Equals(genre)))
                        {
                            display.Append("<div class=\"product\">" + Environment.NewLine);
                            display.Append("<div class=\"inner-product\">" + Environment.NewLine);
                            display.Append("<div class=\"figure-image\">" + Environment.NewLine);
                            display.Append("<a href =\"single.aspx?ID=" + prod.Id + "\">" + Environment.NewLine);
                            display.Append("<img src=\"" + prod.ImageLink + "\"></a>" + Environment.NewLine);
                            display.Append("</div>" + Environment.NewLine);
                            display.Append("<h3 class=\"product-title\"><a href=\"Single.aspx?ID=" + prod.Id + "\">" + prod.Name + "</a></h3>" + Environment.NewLine);
                            display.Append("<small class=\"price\">" + String.Format("{0:C2}", prod.Price) + "</small>" + Environment.NewLine);
                            display.Append("<br />");
                            display.Append("</div>" + Environment.NewLine);
                            display.Append("</div>" + Environment.NewLine);
                        }
                    }
                }
                else
                {
                    testMsg.InnerHtml = "Low reached";
                    dynamic game = from g in db.Products
                                   where g.Platfrom.Equals(pageType) && g.Type.Equals(gametype)
                                   orderby g.Price ascending
                                   select g;

                    foreach (Product prod in game)
                    {
                        if ((prod.StockLevels > 0) && (prod.Genre.Equals(genre)))
                        {
                            display.Append("<div class=\"product\">" + Environment.NewLine);
                            display.Append("<div class=\"inner-product\">" + Environment.NewLine);
                            display.Append("<div class=\"figure-image\">" + Environment.NewLine);
                            display.Append("<a href =\"single.aspx?ID=" + prod.Id + "\">" + Environment.NewLine);
                            display.Append("<img src=\"" + prod.ImageLink + "\"></a>" + Environment.NewLine);
                            display.Append("</div>" + Environment.NewLine);
                            display.Append("<h3 class=\"product-title\"><a href=\"Single.aspx?ID=" + prod.Id + "\">" + prod.Name + "</a></h3>" + Environment.NewLine);
                            display.Append("<small class=\"price\">" + String.Format("{0:C2}", prod.Price) + "</small>" + Environment.NewLine);
                            display.Append("<br />");
                            display.Append("</div>" + Environment.NewLine);
                            display.Append("</div>" + Environment.NewLine);
                        }
                    }
                }
            }
            prodList.InnerHtml = display.ToString();
            display.Clear();
        }