public IHttpActionResult PostUrun(Urun urun) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Urun.Add(urun); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = urun.UrunId }, urun); }
public IHttpActionResult PutUrun(int id, Urun urun) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != urun.UrunId) { return BadRequest(); } db.Entry(urun).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!UrunExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }