示例#1
0
        public IHttpActionResult Putpeopletype(int id, peopletype peopletype)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#2
0
        public IHttpActionResult Getpeopletype(int id)
        {
            peopletype peopletype = db.peopletypes.Find(id);

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

            return(Ok(peopletype));
        }
示例#3
0
        public IHttpActionResult Postpeopletype(peopletype peopletype)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.peopletypes.Add(peopletype);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = peopletype.ID }, peopletype));
        }
示例#4
0
        public IHttpActionResult Deletepeopletype(int id)
        {
            peopletype peopletype = db.peopletypes.Find(id);

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

            db.peopletypes.Remove(peopletype);
            db.SaveChanges();

            return(Ok(peopletype));
        }