Esempio n. 1
0
        public IHttpActionResult PutCaus(int id, Caus caus)
        {
            db.Configuration.ProxyCreationEnabled = false;
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != caus.Cause_ID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 2
0
        public IHttpActionResult GetCaus(int id)
        {
            db.Configuration.ProxyCreationEnabled = false;
            Caus caus = db.Causes.Find(id);

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

            return(Ok(caus));
        }
Esempio n. 3
0
        public IHttpActionResult PostCaus(Caus caus)
        {
            db.Configuration.ProxyCreationEnabled = false;
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Causes.Add(caus);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = caus.Cause_ID }, caus));
        }
Esempio n. 4
0
        public IHttpActionResult DeleteCaus(int id)
        {
            db.Configuration.ProxyCreationEnabled = false;
            Caus caus = db.Causes.Find(id);

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

            db.Causes.Remove(caus);
            db.SaveChanges();

            return(Ok(caus));
        }