コード例 #1
0
        public IHttpActionResult Putsurveyarea(int id, surveyarea surveyarea)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != surveyarea.ID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #2
0
        public IHttpActionResult Getsurveyarea(int id)
        {
            surveyarea surveyarea = db.surveyareas.Find(id);

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

            return(Ok(surveyarea));
        }
コード例 #3
0
        public IHttpActionResult Postsurveyarea(surveyarea surveyarea)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.surveyareas.Add(surveyarea);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = surveyarea.ID }, surveyarea));
        }
コード例 #4
0
        public IHttpActionResult Deletesurveyarea(int id)
        {
            surveyarea surveyarea = db.surveyareas.Find(id);

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

            db.surveyareas.Remove(surveyarea);
            db.SaveChanges();

            return(Ok(surveyarea));
        }