Ejemplo n.º 1
0
        /// <summary>
        ///     Format the monthly data to display for each month in the selected state's data
        /// </summary>
        /// <returns></returns>
        public string FormatMonthlyData()
        {
            var stateData  = new StateDataCalculations(this.Covid19Data);
            var firstMonth = stateData.DateOfFirstPositive().Month;
            var lastMonth  = stateData.DateOfLastTest().Month;

            var monthData = "MONTHLY DATA: \n";

            for (var month = firstMonth; month <= lastMonth; month++)
            {
                monthData += this.monthData(month);

                monthData += Environment.NewLine;
            }

            return(monthData);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Format the overall data from the selected state to be displayed
        /// </summary>
        /// <param name="state"></param>
        /// <returns></returns>
        public string FormatStateData(StateAbbreviations state)
        {
            var stateDataCalculations = new StateDataCalculations(this.Covid19Data);
            var stateData             = state + ": " + Environment.NewLine;

            stateData +=
                $"First Positive Test occurred on {stateDataCalculations.DateOfFirstPositive().ToShortDateString()}\n";
            var highestPos = stateDataCalculations.DataWithHighestNumberOfPositives();

            stateData +=
                $"Highest Number of Positive Tests: {highestPos.PositiveIncrease:n0} occurred on {highestPos.DataDate.ToShortDateString()}\n";
            var highestNeg = stateDataCalculations.DataWithHighestNumberOfNegatives();

            stateData +=
                $"Highest Number of Negative Tests: {highestNeg.NegativeIncrease:n0} occurred on {highestNeg.DataDate.ToShortDateString()}\n";
            var highestTests = stateDataCalculations.DataWithHighestNumberTests();

            stateData +=
                $"Highest Number of Tests: {highestTests.TotalTest:n0} occurred on {highestTests.DataDate.ToShortDateString()}\n";
            var highestDeaths = stateDataCalculations.DataWithHighestNumberDeaths();

            stateData +=
                $"Highest Number of Deaths: {highestDeaths.DeathIncrease:n0} occurred on {highestDeaths.DataDate.ToShortDateString()}\n";
            var highestHospital = stateDataCalculations.DataWithHighestHospitalization();

            stateData +=
                $"Highest Number of Hospitalizations: {highestHospital.HospitalizedIncrease:n0} occurred on {highestHospital.DataDate.ToShortDateString()}\n";
            var highestPercent = stateDataCalculations.DataWithHighestPercentPos();

            stateData +=
                $"Highest Percentage Positive Tests: {highestPercent.FindPercentPositive()}% occurred on {highestPercent.DataDate.ToShortDateString()}\n";

            stateData +=
                $"Average number of Positive Tests: {stateDataCalculations.AverageNumberPositiveSinceFirst():n2}\n";
            stateData += $"Positivity Rate of all Tests:  {stateDataCalculations.FindPositivityRate():n2}% \n";
            stateData +=
                $"Number of Days with positives tests greater than {this.UpperThreshold}: {stateDataCalculations.NumberOfDaysWithPositivesGreaterThan(this.UpperThreshold):n0}\n";
            stateData +=
                $"Number of Days with positives tests less than {this.LowerThreshold}: {stateDataCalculations.NumberOfDaysWithPositiveLessThan(this.LowerThreshold):n0}\n";
            stateData += "BreakDown of Positive Cases: " + Environment.NewLine +
                         formatPositiveCaseBreakdown(stateDataCalculations);
            return(stateData);
        }
Ejemplo n.º 3
0
        private static string formatPositiveCaseBreakdown(StateDataCalculations stateDataCalculations)
        {
            var caseBreakDown = stateDataCalculations.PositiveCaseBreakdown();

            return(caseBreakDown.Aggregate(string.Empty, (current, currBucket) => current + $"{currBucket.Key} : {currBucket.Value,5:N0}" + Environment.NewLine));
        }