public async Task <ActionResult <locataire> > Postlocataire(locataire locataire) { _context.locataires.Add(locataire); await _context.SaveChangesAsync(); return(CreatedAtAction("Getlocataire", new { id = locataire.Id }, locataire)); }
public async Task <IActionResult> Putlocataire(int id, locataire locataire) { if (id != locataire.Id) { return(BadRequest()); } _context.Entry(locataire).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!locataireExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }