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

            if (id != deliveryDetail.deliveryid)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #2
0
        public IHttpActionResult GetdeliveryDetail(int id)
        {
            deliveryDetail deliveryDetail = db.deliveryDetails.Find(id);

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

            return(Ok(deliveryDetail));
        }
예제 #3
0
        public IHttpActionResult PostdeliveryDetail(deliveryDetail deliveryDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.deliveryDetails.Add(deliveryDetail);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = deliveryDetail.deliveryid }, deliveryDetail));
        }
예제 #4
0
        public IHttpActionResult DeletedeliveryDetail(int id)
        {
            deliveryDetail deliveryDetail = db.deliveryDetails.Find(id);

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

            db.deliveryDetails.Remove(deliveryDetail);
            db.SaveChanges();

            return(Ok(deliveryDetail));
        }