Ejemplo n.º 1
0
        private void Polacz()
        {
            IEnumerable <Comic>       comics   = BuildCatalog();           //getting list of comics
            Dictionary <int, decimal> values   = GetPrices();              //getting prices
            IEnumerable <Purchases>   purchase = Purchases.FindPurchase(); //getting purchases list
            var results =
                from comic in comics
                join buy in purchase
                on comic.Issue equals buy.Issue //checking if any of issues are same and getting em if same
                orderby comic.Issue ascending
                select new
            {    //creating object
                Comic       = comic,
                Price       = buy.Price,
                Title       = comic.Name,
                Subtitle    = "Numer " + comic.Issue,
                Description = String.Format("Kupiony za {0:c}", buy.Price),
                Image       = CreateImageFromAssets("yah643x900"),
            };
            decimal listvalue  = 0;
            decimal totalspent = 0;

            //how much was spent on new comics.
            foreach (var result in results)
            {
                listvalue  += values[result.Comic.Issue];
                totalspent += result.Price;
                CurrenQueryResults.Add(result);
            }
            Title = String.Format("Wydane zostalo {0:c} na komiksy warte {1:c}", totalspent, listvalue);
        }
Ejemplo n.º 2
0
 private void AllComics()
 {
     foreach (Comic comic in BuildCatalog())
     {//creating list of all comics
         var result = new
         {
             Image       = CreateImageFromAssets("new_grah1920x1080.jpg"),
             Title       = comic.Name,
             Subtitle    = "Numer " + comic.Issue,
             Description = ":(",
             Comic       = comic,
         };
         CurrenQueryResults.Add(result); //adding results to result list view
     }
 }
Ejemplo n.º 3
0
        private void CheapComics()
        {//working same as ExpensiveComics method, difference is that we are getting here to results all comics < 500
            IEnumerable <Comic>       comics = BuildCatalog();
            Dictionary <int, decimal> values = GetPrices();

            var mostExpensive = from comIc in comics

                                where values[comIc.Issue] < 500
                                orderby values[comIc.Issue] descending
                                select comIc;


            foreach (Comic comic in mostExpensive)
            {
                CurrenQueryResults.Add(
                    new
                {
                    Title = string.Format("{0} jest wart {1:c} ", comic.Name, values[comic.Issue]),
                    Image = CreateImageFromAssets("new_grah1920x1080.jpg"),
                });
            }
        }
Ejemplo n.º 4
0
        //getting comics that are above 500
        private void ExpensiveComics()
        {
            IEnumerable <Comic>       comics = BuildCatalog(); //getting list with comics
            Dictionary <int, decimal> values = GetPrices();    //getting dict with prices

            var mostExpensive = from comIc in comics

                                where values[comIc.Issue] > 500 //selectin all with value > 500
                                orderby values[comIc.Issue] descending
                                select comIc;


            foreach (Comic comic in mostExpensive)
            {
                CurrenQueryResults.Add(
                    new
                {    //adding elements of mostExpensive to result listView collection
                    Title = string.Format("{0} jest wart {1:c} ", comic.Name, values[comic.Issue]),
                    Image = CreateImageFromAssets("new_grah1920x1080.jpg"),
                });
            }
        }
Ejemplo n.º 5
0
        private void GroupByPrice()
        {
            Dictionary <int, decimal> values = GetPrices();
            var priceGroups =
                from pair in values
                group pair.Key by Purchases.EvaluatePrice((int)pair.Value)//checking if they are expsnive or cheap or maybe midrange
                into priceGroup
                orderby priceGroup.Key descending
                select priceGroup;

            foreach (var group in priceGroups)
            {
                string message = String.Format("Found {0} {1} komiksow numery ", group.Count(), group.Key.ToString());

                foreach (var issue in group)
                {//creating new objects on result
                    message += issue.ToString() + " ";
                    CurrenQueryResults.Add(CreateAnonymousListViewItem(message)
                                           );
                }
            }
        }