示例#1
0
        public IHttpActionResult Putviolationcode(int id, violationcode violationcode)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#2
0
        public IHttpActionResult Getviolationcode(int id)
        {
            violationcode violationcode = db.violationcodes.Find(id);

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

            return(Ok(violationcode));
        }
示例#3
0
        public IHttpActionResult Postviolationcode(violationcode violationcode)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.violationcodes.Add(violationcode);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = violationcode.ID }, violationcode));
        }
示例#4
0
        public IHttpActionResult Deleteviolationcode(int id)
        {
            violationcode violationcode = db.violationcodes.Find(id);

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

            db.violationcodes.Remove(violationcode);
            db.SaveChanges();

            return(Ok(violationcode));
        }