예제 #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));
        }
예제 #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));
        }
예제 #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));
        }
예제 #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));
        }