public IHttpActionResult PutEspai(int id, Espai espai) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != espai.id) { return(BadRequest()); } db.Entry(espai).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!EspaiExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetEspai(int id) { Espai espai = db.Espai.Find(id); if (espai == null) { return(NotFound()); } return(Ok(espai)); }
public IHttpActionResult PostEspai(Espai espai) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Espai.Add(espai); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = espai.id }, espai)); }
public IHttpActionResult DeleteEspai(int id) { Espai espai = db.Espai.Find(id); if (espai == null) { return(NotFound()); } db.Espai.Remove(espai); db.SaveChanges(); return(Ok(espai)); }