示例#1
0
        private static int totalDailyTests(CovidCase theData)
        {
            if (theData == null)
            {
                throw new ArgumentOutOfRangeException(nameof(theData));
            }

            return(theData.PositiveIncrease + theData.NegativeIncrease);
        }
示例#2
0
        /// <summary>
        /// Removes a duplicate entry
        /// </summary>
        public void RemoveDuplicateEntry(CovidCase covidCase)
        {
            var item  = this.duplicateCases.First(i => i.Date.Equals(covidCase.Date));
            var index = this.duplicateCases.IndexOf(item);

            if (index != -1)
            {
                this.duplicateCases.RemoveAt(index);
            }
        }
示例#3
0
        /// <summary>
        ///     Finds and Replaces a covid case with the exact date.
        /// </summary>
        public void FindAndReplace(CovidCase covidCase)
        {
            var item  = this.locationsCovidCases.First(i => i.Date.Equals(covidCase.Date));
            var index = this.locationsCovidCases.IndexOf(item);

            if (index != -1)
            {
                this.locationsCovidCases.RemoveAt(index);
                this.locationsCovidCases.Add(covidCase);
            }
        }
示例#4
0
        /// <summary>
        ///     Adds a single covid case to the collection
        /// </summary>
        /// <param name="covidCase">The covid case to be added</param>
        /// <exception cref="ArgumentNullException">covidCase cannot be null</exception>
        public void AddCovidCase(CovidCase covidCase)
        {
            if (covidCase == null)
            {
                throw new ArgumentNullException(nameof(covidCase));
            }

            if (this.locationsCovidCases.Any(covid => covid.Date.Equals(covidCase.Date)))
            {
                this.duplicateCases.Add(covidCase);
            }
            else
            {
                this.locationsCovidCases.Add(covidCase);
                // this.locationsCovidCases = this.SortData();
            }
        }
示例#5
0
        /// <summary>
        ///     Calculates the percent of positive covid tests for a covid object.
        /// </summary>
        /// <param name="theData">The data.</param>
        /// <returns>
        ///     The percent of positive covid test for a covidData object
        /// </returns>
        /// <exception cref="ArgumentOutOfRangeException">theData</exception>
        public double PositiveTestPercent(CovidCase theData)
        {
            if (theData == null)
            {
                throw new ArgumentOutOfRangeException(nameof(theData));
            }

            double totalTests = totalDailyTests(theData);
            var    percent    = 0.0;

            if (totalTests != 0)
            {
                percent = theData.PositiveIncrease / totalTests;
            }

            return(percent * 100);
        }
        /// <summary>
        ///     Adds the specified covid case to the collection.
        /// </summary>
        /// <param name="covidCase">The covid case you want to add.</param>
        /// <exception cref="ArgumentNullException">covidCase cannot be null</exception>
        public void AddCovidCase(CovidCase covidCase)
        {
            if (covidCase == null)
            {
                throw new ArgumentNullException(nameof(covidCase));
            }

            if (covidLocationDataCollection.ContainsKey(covidCase.Location))
            {
                covidLocationDataCollection[covidCase.Location].AddCovidCase(covidCase);
            }
            else
            {
                CovidLocationData newState = new CovidLocationData(covidCase.Location);
                covidLocationDataCollection.Add(newState.State, newState);
                covidLocationDataCollection[covidCase.Location].AddCovidCase(covidCase);
            }
        }