예제 #1
0
        public IHttpActionResult PutCausationType(int id, CausationType causationType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != causationType.Id)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #2
0
        public IHttpActionResult GetCausationType(int id)
        {
            CausationType causationType = db.CausationTypes.Find(id);

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

            return(Ok(causationType));
        }
예제 #3
0
        public IHttpActionResult PostCausationType(CausationType causationType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.CausationTypes.Add(causationType);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = causationType.Id }, causationType));
        }
예제 #4
0
        public IHttpActionResult DeleteCausationType(int id)
        {
            CausationType causationType = db.CausationTypes.Find(id);

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

            db.CausationTypes.Remove(causationType);
            db.SaveChanges();

            return(Ok(causationType));
        }