示例#1
0
        public IHttpActionResult PutFlightBookSummary(int id, FlightBookSummary flightBookSummary)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != flightBookSummary.bookID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#2
0
        public IHttpActionResult PostFlightBookSummary(FlightBookSummary flightBookSummary)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.FlightBookSummaries.Add(flightBookSummary);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = flightBookSummary.bookID }, flightBookSummary));
        }
示例#3
0
        public IHttpActionResult DeleteFlightBookSummary(int id)
        {
            FlightBookSummary flightBookSummary = db.FlightBookSummaries.Find(id);

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

            db.FlightBookSummaries.Remove(flightBookSummary);
            db.SaveChanges();

            return(Ok(flightBookSummary));
        }