Пример #1
0
        public IHttpActionResult PostBookingRecordDetail(BookingRecordDetail bookingRecordDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.BookingRecordDetails.Add(bookingRecordDetail);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (BookingRecordDetailExists(bookingRecordDetail.BookingRecordDetail_ID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = bookingRecordDetail.BookingRecordDetail_ID }, bookingRecordDetail));
        }
Пример #2
0
        public IHttpActionResult PutBookingRecordDetail(int id, BookingRecordDetail bookingRecordDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != bookingRecordDetail.BookingRecordDetail_ID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #3
0
        public IHttpActionResult GetBookingRecordDetail(int id)
        {
            BookingRecordDetail bookingRecordDetail = db.BookingRecordDetails.Find(id);

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

            return(Ok(bookingRecordDetail));
        }
Пример #4
0
        public IHttpActionResult DeleteBookingRecordDetail(int id)
        {
            BookingRecordDetail bookingRecordDetail = db.BookingRecordDetails.Find(id);

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

            db.BookingRecordDetails.Remove(bookingRecordDetail);
            db.SaveChanges();

            return(Ok(bookingRecordDetail));
        }