コード例 #1
0
ファイル: CandidateCall.cs プロジェクト: TicoSource/Eval
 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);
            }
        }