public async Task<IHttpActionResult> PostTipoGarantia(TipoGarantia tipoGarantia) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.TiposGarantia.Add(tipoGarantia); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (TipoGarantiaExists(tipoGarantia.Id)) { return Conflict(); } else { throw; } } return CreatedAtRoute("DefaultApi", new { id = tipoGarantia.Id }, tipoGarantia); }
public async Task<IHttpActionResult> PutTipoGarantia(string id, TipoGarantia tipoGarantia) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != tipoGarantia.Id) { return BadRequest(); } db.Entry(tipoGarantia).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TipoGarantiaExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }