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

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

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

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

            return StatusCode(HttpStatusCode.NoContent);
        }
コード例 #2
0
        public IHttpActionResult PostGoogleMap(GoogleMap googleMap)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.GoogleMaps.Add(googleMap);
            db.SaveChanges();

            return CreatedAtRoute("DefaultApi", new { id = googleMap.Id }, googleMap);
        }