public async Task <IActionResult> Edit(int id, [Bind("Id,Date,NumVaccinated,NumDeaths,NumRecovered,NewCases")] DayRecord dayRecord) { if (id != dayRecord.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(dayRecord); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DayRecordExists(dayRecord.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(dayRecord)); }
public CasoCovid Salvar(CasoCovid caso) { if (_banco.CasosCovid.AsNoTracking().FirstOrDefault(x => x.Id == caso.Id) != null) { _banco.Update(caso); } else { _banco.Add(caso); } _banco.SaveChanges(); return(caso); }