public IHttpActionResult PostIstasyon(Istasyon istasyon) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Istasyon.Add(istasyon); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = istasyon.IstasyonId }, istasyon); }
public IHttpActionResult PutIstasyon(int id, Istasyon istasyon) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != istasyon.IstasyonId) { return BadRequest(); } db.Entry(istasyon).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!IstasyonExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }