public async Task <IActionResult> Create([Bind("DateTest,Resultat,TypeDeTest")] TestCovid testCovid) { testCovid.Id = Guid.NewGuid(); _context.Add(testCovid); await _context.SaveChangesAsync(); return(Created($"TestsCovid/{testCovid.Id}", testCovid)); }
public async Task <IActionResult> Create([Bind("Id,Date,NumVaccinated,NumDeaths,NumRecovered,NewCases")] DayRecord dayRecord) { if (ModelState.IsValid) { _context.Add(dayRecord); await _context.SaveChangesAsync(); 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); }
public async Task <IActionResult> Create([Bind("DateTest,Resultat,TypeDeTest")] TestCovid testCovid) { var user = _context.Users.Single(x => x.Id == User.FindFirst("Id").Value); if (user.isMedecin) { testCovid.Id = Guid.NewGuid(); _context.Add(testCovid); await _context.SaveChangesAsync(); return(Created($"TestsCovid/{testCovid.Id}", testCovid)); } return(Unauthorized()); }