コード例 #1
0
        public IHttpActionResult PostTrainerPersonalDetail(TrainerPersonalDetail trainerpersonaldetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.TrainerPersonalDetails.Add(trainerpersonaldetail);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (TrainerPersonalDetailExists(trainerpersonaldetail.TrainerPersonalId))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = trainerpersonaldetail.TrainerPersonalId }, trainerpersonaldetail));
        }
コード例 #2
0
        // PUT api/TrainerPersonal/5
        public IHttpActionResult PutTrainerPersonalDetail(int id, TrainerPersonalDetail trainerpersonaldetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != trainerpersonaldetail.TrainerPersonalId)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #3
0
        public IHttpActionResult GetTrainerPersonalDetail(int id)
        {
            TrainerPersonalDetail trainerpersonaldetail = db.TrainerPersonalDetails.Find(id);

            if (trainerpersonaldetail == null)
            {
                return(NotFound());
            }

            return(Ok(trainerpersonaldetail));
        }
コード例 #4
0
        public IHttpActionResult DeleteTrainerPersonalDetail(int id)
        {
            TrainerPersonalDetail trainerpersonaldetail = db.TrainerPersonalDetails.Find(id);

            if (trainerpersonaldetail == null)
            {
                return(NotFound());
            }

            db.TrainerPersonalDetails.Remove(trainerpersonaldetail);
            db.SaveChanges();

            return(Ok(trainerpersonaldetail));
        }