예제 #1
0
        public IHttpActionResult PutPartyVehicle(long id, PartyVehicle partyVehicle)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != partyVehicle.ID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #2
0
        public IHttpActionResult GetPartyVehicle(long id)
        {
            PartyVehicle partyVehicle = db.PartyVehicles.Find(id);

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

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

            db.PartyVehicles.Add(partyVehicle);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = partyVehicle.ID }, partyVehicle));
        }
예제 #4
0
        public IHttpActionResult DeletePartyVehicle(long id)
        {
            PartyVehicle partyVehicle = db.PartyVehicles.Find(id);

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

            db.PartyVehicles.Remove(partyVehicle);
            db.SaveChanges();

            return(Ok(partyVehicle));
        }