public IHttpActionResult PostAdmissionInfo(AdmissionInfo admissioninfo) { if (!ModelState.IsValid) { return BadRequest(ModelState); } try { //db.SaveChanges(); //admissioninfo.StdtId = admissioninfo.StudentInfo.StudentId; db.StudentInfoes.Add(admissioninfo.StudentInfo); db.AdmissionInfoes.Add(admissioninfo); db.SaveChanges(); } catch (DbUpdateException) { if (AdmissionInfoExists(admissioninfo.AdmId)) { return Conflict(); } else { throw; } } return CreatedAtRoute("DefaultApi", new { id = admissioninfo.AdmId }, admissioninfo); }
// PUT api/AdmissionInfo/5 public IHttpActionResult PutAdmissionInfo(int id, AdmissionInfo admissioninfo) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != admissioninfo.AdmId) { return BadRequest(); } db.Entry(admissioninfo).State = EntityState.Modified; db.Entry(admissioninfo.StudentInfo).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!AdmissionInfoExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }