Пример #1
0
        public IHttpActionResult PutPurchaseTicketLineItem(int id, PurchaseTicketLineItem purchaseTicketLineItem)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != purchaseTicketLineItem.Id)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #2
0
        public IHttpActionResult GetPurchaseTicketLineItem(int id)
        {
            PurchaseTicketLineItem purchaseTicketLineItem = db.PurchaseTicketLineItems.Find(id);

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

            return(Ok(purchaseTicketLineItem));
        }
Пример #3
0
        public IHttpActionResult PostPurchaseTicketLineItem(PurchaseTicketLineItem purchaseTicketLineItem)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.PurchaseTicketLineItems.Add(purchaseTicketLineItem);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = purchaseTicketLineItem.Id }, purchaseTicketLineItem));
        }
Пример #4
0
        public IHttpActionResult DeletePurchaseTicketLineItem(int id)
        {
            PurchaseTicketLineItem purchaseTicketLineItem = db.PurchaseTicketLineItems.Find(id);

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

            db.PurchaseTicketLineItems.Remove(purchaseTicketLineItem);
            db.SaveChanges();

            return(Ok(purchaseTicketLineItem));
        }