コード例 #1
0
        public IHttpActionResult Putviolationcas(int id, violationcas violationcas)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #2
0
        public IHttpActionResult Getviolationcas(int id)
        {
            violationcas violationcas = db.violationcases.Find(id);

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

            return(Ok(violationcas));
        }
コード例 #3
0
        public IHttpActionResult Postviolationcas(violationcas violationcas)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.violationcases.Add(violationcas);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = violationcas.ID }, violationcas));
        }
コード例 #4
0
        public IHttpActionResult Deleteviolationcas(int id)
        {
            violationcas violationcas = db.violationcases.Find(id);

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

            db.violationcases.Remove(violationcas);
            db.SaveChanges();

            return(Ok(violationcas));
        }