예제 #1
0
        public IHttpActionResult PutLikeTransport(int id, LikeTransport likeTransport)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != likeTransport.likeId)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #2
0
        public IHttpActionResult PostLikeTransport(LikeTransport likeTransport)
        {
            db.LikeTransports.Add(likeTransport);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = likeTransport.likeId }, likeTransport));
        }
예제 #3
0
        public IHttpActionResult DeleteLikeTransport(int id)
        {
            LikeTransport likeTransport = db.LikeTransports.Find(id);

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

            db.LikeTransports.Remove(likeTransport);
            db.SaveChanges();

            return(Ok(likeTransport));
        }