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());
        }
 public ActionResult Edit([Bind(Include = "ID,Code,Name")] Country country)
 {
     if (ModelState.IsValid)
     {
         db.Entry(country).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(country));
 }
Пример #3
0
 public ActionResult Edit([Bind(Include = "ID,CountryID,Confirmed,Deaths,Recovered,Active,Date")] Case @case)
 {
     if (ModelState.IsValid)
     {
         db.Entry(@case).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CountryID = new SelectList(db.Countries, "ID", "Name", @case.CountryID);
     return(View(@case));
 }