// PUT api/CI/5
        public IHttpActionResult PutCrimeInstance(int id, CrimeInstance crimeinstance)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #2
0
        protected void ReportSubmit_Click(object sender, EventArgs e)
        {
            DateTime?my_date;
            float?   c_lat, c_long;

            try {
                my_date = DateTime.Parse(c_date.Value);
            }
            catch
            {
                my_date = null;
            }
            try
            {
                c_lat  = float.Parse(latMap.Value);
                c_long = float.Parse(lngMap.Value);
            }
            catch
            {
            }

            using (CrimeDBEntities CE = new CrimeDBEntities())
            {
                var ci = new CrimeInstance
                {
                    detail   = c_detail.Value,
                    date     = my_date,
                    category = Int32.Parse(c_category.Value)
                };
                CE.CrimeInstances.Add(ci);
                CE.SaveChanges();
            }
        }
        protected void ReportSubmit_Click(object sender, EventArgs e)
        {
            DateTime? my_date;
            float? c_lat, c_long;
            try {
                my_date = DateTime.Parse(c_date.Value);
            }
            catch
            {
                my_date = null;
            }
            try
            {
                c_lat = float.Parse(latMap.Value);
                c_long = float.Parse(lngMap.Value);
            }
            catch
            {

            }

            using (CrimeDBEntities CE = new CrimeDBEntities())
            {
                var ci = new CrimeInstance
                {
                    detail = c_detail.Value,
                    date = my_date,
                    category = Int32.Parse(c_category.Value)
                };
                CE.CrimeInstances.Add(ci);
                CE.SaveChanges();
            }
        }