public async Task <IHttpActionResult> PutPatinete(int id, Patinete patinete) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != patinete.Id) { return(BadRequest()); } db.Entry(patinete).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PatineteExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> GetPatinete(int id) { Patinete patinete = await db.Patinetes.FindAsync(id); if (patinete == null) { return(NotFound()); } return(Ok(patinete)); }
public async Task <IHttpActionResult> PostPatinete(Patinete patinete) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Patinetes.Add(patinete); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = patinete.Id }, patinete)); }
public async Task <IHttpActionResult> DeletePatinete(int id) { Patinete patinete = await db.Patinetes.FindAsync(id); if (patinete == null) { return(NotFound()); } db.Patinetes.Remove(patinete); await db.SaveChangesAsync(); return(Ok(patinete)); }