public IHttpActionResult PutGruni(int id, Gruni gruni) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != gruni.cd_gruni) { return BadRequest(); } db.Entry(gruni).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!GruniExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostGruni(Gruni gruni) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Gruni.Add(gruni); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = gruni.cd_gruni }, gruni); }