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

            if (id != policeReported.PoliceReportedId)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#2
0
        public ActionResult DeleteConfirmed(int id)
        {
            PoliceReported policeReported = db.PoliceReported.Find(id);

            db.PoliceReported.Remove(policeReported);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#3
0
 public ActionResult Edit([Bind(Include = "id,value")] PoliceReported policeReported)
 {
     if (ModelState.IsValid)
     {
         db.Entry(policeReported).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(policeReported));
 }
示例#4
0
        public ActionResult Create([Bind(Include = "id,value")] PoliceReported policeReported)
        {
            if (ModelState.IsValid)
            {
                db.PoliceReported.Add(policeReported);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(policeReported));
        }
示例#5
0
        public IHttpActionResult GetPoliceReported(int id)
        {
            PoliceReported policeReported = db.PoliceReporteds.Find(id);

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

            return(Ok(policeReported));
        }
示例#6
0
        public IHttpActionResult PostPoliceReported(PoliceReported policeReported)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.PoliceReporteds.Add(policeReported);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = policeReported.PoliceReportedId }, policeReported));
        }
示例#7
0
        // GET: PoliceReporteds/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PoliceReported policeReported = db.PoliceReported.Find(id);

            if (policeReported == null)
            {
                return(HttpNotFound());
            }
            return(View(policeReported));
        }
示例#8
0
        public IHttpActionResult DeletePoliceReported(int id)
        {
            PoliceReported policeReported = db.PoliceReporteds.Find(id);

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

            db.PoliceReporteds.Remove(policeReported);
            db.SaveChanges();

            return(Ok(policeReported));
        }