// PUT api/Hospital/5 public IHttpActionResult PutHospital(int id, Hospital hospital) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != hospital.HospitalId) { return BadRequest(); } db.Entry(hospital).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!HospitalExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostHospital(Hospital hospital) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Hospital.Add(hospital); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = hospital.HospitalId }, hospital); }