Пример #1
0
        public PieChartMissingIssueRatio GetPieChartData(int publisherId)
        {
            PieChartMissingIssueRatio ratios = new PieChartMissingIssueRatio();

            ratios.MissingIssueRatioList.Add(new KeyValuePair <string, int>("Collected", 2));
            ratios.MissingIssueRatioList.Add(new KeyValuePair <string, int>("Missing", 4));
            return(ratios);
        }
Пример #2
0
        public void CanGetPieChartData()
        {
            PieChartMissingIssueRatio ratios = repository.GetPieChartData(-1);

            Assert.IsTrue(ratios.MissingIssueRatioList[0].Key == "Collected");
            Assert.IsTrue(ratios.MissingIssueRatioList[0].Value == 2);
            Assert.IsTrue(ratios.MissingIssueRatioList[1].Key == "Missing");
            Assert.IsTrue(ratios.MissingIssueRatioList[1].Value == 4);
        }
Пример #3
0
        private ObservableCollection <KeyValuePair <string, int> > ReloadPieChart(int publisherId)
        {
            var pieChartRatios = new ObservableCollection <KeyValuePair <string, int> >();
            PieChartMissingIssueRatio ratios = repository.GetPieChartData(publisherId);

            foreach (KeyValuePair <string, int> ratio in ratios.MissingIssueRatioList)
            {
                pieChartRatios.Add(ratio);
            }
            return(pieChartRatios);
        }
Пример #4
0
        public PieChartMissingIssueRatio GetPieChartData(int publisherId)
        {
            PieChartMissingIssueRatio pieChartData = new PieChartMissingIssueRatio();

            using (SqlConnection con = new SqlConnection(constring))
            {
                int        issueCount        = 0;
                int        missingIssueCount = 0;
                SqlCommand command           = new SqlCommand("select count(i.id) as count from issue i join volume v on i.volume_id = v.id join publisher p on p.id = v.publisher_id where p.id = @id and v.collectable = 1 and i.collected = 1", con);
                command.Parameters.Add("@id", SqlDbType.Int).Value = publisherId;
                SqlDataAdapter ad = new SqlDataAdapter(command);
                DataSet        ds = new DataSet("issueCount");
                ad.Fill(ds);
                if (ds.Tables[0].Rows.Count != 0)
                {
                    string strIssueCount = ds.Tables[0].Rows[0]["count"].ToString();
                    issueCount = 0;
                    Int32.TryParse(strIssueCount, out issueCount);
                }

                SqlCommand missingCommand = new SqlCommand("select count(i.id) as count from issue i join volume v on i.volume_id = v.id join publisher p on p.id = v.publisher_id where p.id = @id and v.collectable = 1 and i.collected = 0", con);
                missingCommand.Parameters.Add("@id", SqlDbType.Int).Value = publisherId;
                SqlDataAdapter missingad = new SqlDataAdapter(missingCommand);
                DataSet        missingds = new DataSet("issueMissingCount");
                missingad.Fill(missingds);
                if (missingds.Tables[0].Rows.Count != 0)
                {
                    string strMissingIssueCount = missingds.Tables[0].Rows[0]["count"].ToString();
                    missingIssueCount = 0;
                    Int32.TryParse(strMissingIssueCount, out missingIssueCount);
                }

                pieChartData.MissingIssueRatioList.Add(new KeyValuePair <string, int>("Collected", issueCount));
                pieChartData.MissingIssueRatioList.Add(new KeyValuePair <string, int>("Missing", missingIssueCount));
            }
            return(pieChartData);
            //TODO Test GetPieChartData
        }