示例#1
0
        public IHttpActionResult PostCall(CandidateCall call)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            call.Candidate = db.Cadidates.Find(call.Candidate.CandidateID);
            db.Calls.Add(call);
            db.SaveChanges();

            return CreatedAtRoute("DefaultApi", new { id = call.CandidateCallID }, call);
        }
示例#2
0
        public IHttpActionResult PutCall(int id, CandidateCall call)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != call.CandidateCallID)
            {
                return BadRequest();
            }

            db.Entry(call).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CallExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }