public IHttpActionResult PutApplicant(int id, Applicant applicant) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != applicant.Id) { return(BadRequest()); } db.Entry(applicant).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ApplicantExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
//create a new record public void CreateApplicant(Applicant applicant) { db.Applicants.Add(applicant); try { db.SaveChanges(); } catch (DbUpdateException ex) { throw ex; } }