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

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

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

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

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

            db.Garcoms.Add(garcom);
            db.SaveChanges();

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