Ejemplo n.º 1
0
        public IHttpActionResult PutCaution(int id, Caution caution)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

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

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

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

            return StatusCode(HttpStatusCode.NoContent);
        }
Ejemplo n.º 2
0
        public IHttpActionResult PostCaution(Caution caution)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.Cautions.Add(caution);
            db.SaveChanges();

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