Exemple #1
0
        // GET api/CandidateType/5
        public CANDIDATETYPE GetCANDIDATETYPE(string id)
        {
            CANDIDATETYPE candidatetype = db.CANDIDATETYPEs.Find(id);

            if (candidatetype == null)
            {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            return(candidatetype);
        }
Exemple #2
0
        // POST api/CandidateType
        public HttpResponseMessage PostCANDIDATETYPE(CANDIDATETYPE candidatetype)
        {
            if (ModelState.IsValid)
            {
                db.CANDIDATETYPEs.Add(candidatetype);
                db.SaveChanges();

                HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, candidatetype);
                response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = candidatetype.ID_CANDIDATE }));
                return(response);
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }
Exemple #3
0
        // DELETE api/CandidateType/5
        public HttpResponseMessage DeleteCANDIDATETYPE(string id)
        {
            CANDIDATETYPE candidatetype = db.CANDIDATETYPEs.Find(id);

            if (candidatetype == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            db.CANDIDATETYPEs.Remove(candidatetype);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, candidatetype));
        }
Exemple #4
0
        // PUT api/CandidateType/5
        public HttpResponseMessage PutCANDIDATETYPE(string id, CANDIDATETYPE candidatetype)
        {
            if (ModelState.IsValid && id == candidatetype.ID_CANDIDATE)
            {
                db.Entry(candidatetype).State = EntityState.Modified;

                try
                {
                    db.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    return(Request.CreateResponse(HttpStatusCode.NotFound));
                }

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }