Exemple #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));
        }
Exemple #2
0
        public IHttpActionResult GetOnMyWay(int id)
        {
            OnMyWay onmyway = db.OnMyWays.Find(id);

            if (onmyway == null)
            {
                return(NotFound());
            }

            return(Ok(onmyway));
        }
Exemple #3
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));
        }
Exemple #4
0
        public IHttpActionResult DeleteOnMyWay(int id)
        {
            OnMyWay onmyway = db.OnMyWays.Find(id);

            if (onmyway == null)
            {
                return(NotFound());
            }

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

            return(Ok(onmyway));
        }