Ejemplo n.º 1
0
        public IHttpActionResult PutVoyagerBill(int id, VoyagerBill voyagerBill)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != voyagerBill.VoyagerBillId)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 2
0
        public IHttpActionResult GetVoyagerBill(int id)
        {
            VoyagerBill voyagerBill = db.Bills.Find(id);

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

            return(Ok(voyagerBill));
        }
Ejemplo n.º 3
0
        public IHttpActionResult PostVoyagerBill(VoyagerBill voyagerBill)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Bills.Add(voyagerBill);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = voyagerBill.VoyagerBillId }, voyagerBill));
        }
Ejemplo n.º 4
0
        public IHttpActionResult DeleteVoyagerBill(int id)
        {
            VoyagerBill voyagerBill = db.Bills.Find(id);

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

            db.Bills.Remove(voyagerBill);
            db.SaveChanges();

            return(Ok(voyagerBill));
        }