public async Task <IHttpActionResult> PutAutomovelMarca(int id, AutomovelMarca automovelMarca) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != automovelMarca.Id) { return(BadRequest()); } db.Entry(automovelMarca).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AutomovelMarcaExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> GetAutomovelMarca(int id) { AutomovelMarca automovelMarca = await db.AutomovelMarcas.FindAsync(id); if (automovelMarca == null) { return(NotFound()); } return(Ok(automovelMarca)); }
public async Task <IHttpActionResult> PostAutomovelMarca(AutomovelMarca automovelMarca) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.AutomovelMarcas.Add(automovelMarca); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = automovelMarca.Id }, automovelMarca)); }
public async Task <IHttpActionResult> DeleteAutomovelMarca(int id) { AutomovelMarca automovelMarca = await db.AutomovelMarcas.FindAsync(id); if (automovelMarca == null) { return(NotFound()); } db.AutomovelMarcas.Remove(automovelMarca); await db.SaveChangesAsync(); return(Ok(automovelMarca)); }