Exemplo n.º 1
0
        // PUT api/OnMyWay/5
        public IHttpActionResult PutOnMyWay(int id, OnMyWay onmyway)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != onmyway.onMyWayId)
            {
                return BadRequest();
            }

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

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

            return StatusCode(HttpStatusCode.NoContent);
        }
Exemplo n.º 2
0
        public IHttpActionResult PostOnMyWay(OnMyWay onmyway)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.OnMyWays.Add(onmyway);
            db.SaveChanges();

            return CreatedAtRoute("DefaultApi", new { id = onmyway.onMyWayId }, onmyway);
        }