示例#1
0
 public CandidateCall(Condition _condition, Candidate _Candidate, string _date, string _comment)
 {
     Candidate = _Candidate;
     condition = _condition;
     callDate = _date;
     comment = _comment;
 }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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);
            }
        }