public async Task <IActionResult> UpdateCovidItem(long id, CovidItemDTO covidItemDTO)
        {
            if (id != covidItemDTO.Id)
            {
                return(BadRequest());
            }

            var covidItem = new CovidItem {
                Id         = covidItemDTO.Id,
                IsComplete = covidItemDTO.IsComplete,
                Name       = covidItemDTO.Name
            };

            _context.Entry(covidItem).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CovidItemExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("ID,DataRep,day,month,year,cases,deaths,countriesAndTerritories,geoId,countryterritoryCode,popData2018,ContinentExp")] Dataset dataset)
        {
            if (ModelState.IsValid)
            {
                _context.Add(dataset);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(dataset));
        }
Ejemplo n.º 3
0
 public Task <int> Complete()
 {
     return(_context.SaveChangesAsync());
 }