public async Task <IHttpActionResult> Putcandado(int id, candado candado) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != candado.idcandado) { return(BadRequest()); } db.Entry(candado).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!candadoExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> Getcandado(int id) { candado candado = await db.candado.FindAsync(id); if (candado == null) { return(NotFound()); } return(Ok(candado)); }
public async Task <IHttpActionResult> Postcandado(candado candado) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.candado.Add(candado); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = candado.idcandado }, candado)); }
public async Task <IHttpActionResult> Deletecandado(int id) { candado candado = await db.candado.FindAsync(id); if (candado == null) { return(NotFound()); } db.candado.Remove(candado); await db.SaveChangesAsync(); return(Ok(candado)); }