Esempio n. 1
0
        public IHttpActionResult PutKeyPerson1(int id, KeyPerson1 keyPerson1)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != keyPerson1.KeyPersons_id)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 2
0
        public IHttpActionResult GetKeyPerson1(int id)
        {
            KeyPerson1 keyPerson1 = db.KeyPersons1.Find(id);

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

            return(Ok(keyPerson1));
        }
Esempio n. 3
0
        public IHttpActionResult PostKeyPerson1(KeyPerson1 keyPerson1)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.KeyPersons1.Add(keyPerson1);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = keyPerson1.KeyPersons_id }, keyPerson1));
        }
Esempio n. 4
0
        public IHttpActionResult DeleteKeyPerson1(int id)
        {
            KeyPerson1 keyPerson1 = db.KeyPersons1.Find(id);

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

            db.KeyPersons1.Remove(keyPerson1);
            db.SaveChanges();

            return(Ok(keyPerson1));
        }