public IHttpActionResult PostKup(Kup kup) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Kup.Add(kup); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = kup.KupId }, kup); }
public IHttpActionResult PutKup(int id, Kup kup) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != kup.KupId) { return BadRequest(); } db.Entry(kup).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!KupExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }