// POST: odata/TipoLocaciones public async Task <IHttpActionResult> Post(TipoLocacion tipoLocacion) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.TipoLocacion.Add(tipoLocacion); await db.SaveChangesAsync(); return(Created(tipoLocacion)); }
// DELETE: odata/TipoLocaciones(5) public async Task <IHttpActionResult> Delete([FromODataUri] int key) { TipoLocacion tipoLocacion = await db.TipoLocacion.FindAsync(key); if (tipoLocacion == null) { return(NotFound()); } db.TipoLocacion.Remove(tipoLocacion); await db.SaveChangesAsync(); return(StatusCode(HttpStatusCode.NoContent)); }
// PUT: odata/TipoLocaciones(5) public async Task <IHttpActionResult> Put([FromODataUri] int key, Delta <TipoLocacion> patch) { Validate(patch.GetEntity()); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } TipoLocacion tipoLocacion = await db.TipoLocacion.FindAsync(key); if (tipoLocacion == null) { return(NotFound()); } patch.Put(tipoLocacion); try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TipoLocacionExists(key)) { return(NotFound()); } else { throw; } } return(Updated(tipoLocacion)); }