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("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()); }