public async Task <IActionResult> Edit(Guid id, [Bind("ID,Name,Age,Gender,Nationality,CaseStatus,State")] CovidCase covidCase)
        {
            if (id != covidCase.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(covidCase);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CovidCaseExists(covidCase.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(covidCase));
        }
        public void TestConstructor()
        {
            var date      = DateTime.ParseExact("20200816", DateFormat, CultureInfo.InvariantCulture);
            var covidCase = new CovidCase("GA", date);
            var expected  = $"8/16/2020 GA : [+Increase] 0 [-increase] 0 [death increase] 0 [hospitalized increase] 0{ Environment.NewLine}";
            var result    = covidCase.ToString();

            Assert.AreEqual(expected, result, true);
        }
        public async Task <IActionResult> Create([Bind("ID,Name,Age,Gender,Nationality,CaseStatus,State")] CovidCase covidCase)
        {
            if (ModelState.IsValid)
            {
                covidCase.ID = Guid.NewGuid();
                _context.Add(covidCase);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(covidCase));
        }
        private void buttonAddNewEntry_Click(object sender, RoutedEventArgs e)
        {
            this.textBlockCovidEntryErrorMessage.Visibility = Visibility.Collapsed;

            var isEntryValid = this.validateNewEntryData();

            if (isEntryValid)
            {
                var location = this.comboboxState.SelectedValue?.ToString();
                var dateTime = DateTime.Parse(this.datePickerCovidCase.Date.ToString());

                var covidCase = new CovidCase(location, dateTime)
                {
                    PositiveIncrease     = int.Parse(this.textBoxPositiveTests.Text),
                    NegativeIncrease     = int.Parse(this.textBoxNegativeTests.Text),
                    DeathIncrease        = int.Parse(this.textBoxDeaths.Text),
                    HospitalizedIncrease = int.Parse(this.textBoxHospitalizations.Text)
                };


                this.viewModel.CovidCollection.AddCovidCase(covidCase);

                if (this.viewModel.CovidLocationData == null)
                {
                    this.viewModel.CovidLocationData = this.viewModel.CovidCollection.GetLocationData(LocationOfInterest);
                }

                this.clearNewDataEntryFields();
                this.updateDisplay();
            }
            else
            {
                this.textBlockCovidEntryErrorMessage.Text       = "Please Complete All Fields Correctly";
                this.textBlockCovidEntryErrorMessage.Visibility = Visibility.Visible;
            }
        }
Beispiel #5
0
 public void HelpConfirmedCase(
     [FromBody]
     CovidCase c)
 {
     //
 }