public async Task <IHttpActionResult> PosttipoCliente(tipoCliente tipoCliente) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.tipoCliente.Add(tipoCliente); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (tipoClienteExists(tipoCliente.id)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = tipoCliente.id }, tipoCliente)); }
public async Task <IHttpActionResult> PuttipoCliente(int id, tipoCliente tipoCliente) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tipoCliente.id) { return(BadRequest()); } db.Entry(tipoCliente).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!tipoClienteExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> GettipoCliente(int id) { tipoCliente tipoCliente = await db.tipoCliente.FindAsync(id); if (tipoCliente == null) { return(NotFound()); } return(Ok(tipoCliente)); }
public async Task <IHttpActionResult> DeletetipoCliente(int id) { tipoCliente tipoCliente = await db.tipoCliente.FindAsync(id); if (tipoCliente == null) { return(NotFound()); } db.tipoCliente.Remove(tipoCliente); await db.SaveChangesAsync(); return(Ok(tipoCliente)); }