public CandidateCall(Condition _condition, Candidate _Candidate, string _date, string _comment) { Candidate = _Candidate; condition = _condition; callDate = _date; comment = _comment; }
public IHttpActionResult PostCandidate(Candidate candidate) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Cadidates.Add(candidate); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = candidate.CandidateID }, candidate); }
public IHttpActionResult PutCandidate(int id, Candidate candidate) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != candidate.CandidateID) { return BadRequest(); } db.Entry(candidate).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CandidateExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult ModifyCandidate(Candidate updateCandidate) { if (!ModelState.IsValid) { return BadRequest(ModelState); } Candidate oldCandidate = db.Cadidates.Find(updateCandidate.CandidateID); if(oldCandidate != null) { db.Entry(oldCandidate).CurrentValues.SetValues(updateCandidate); db.SaveChanges(); return StatusCode(HttpStatusCode.OK); } else { return StatusCode(HttpStatusCode.NotFound); } }