예제 #1
0
        public async Task<IHttpActionResult> PutPurchaseOrder(Guid id, PurchaseOrder purchaseOrder)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != purchaseOrder.ID)
            {
                return BadRequest();
            }
            new PurchaseMgrAppService(db).UpdatePurchaseOrder(id, purchaseOrder);
            //db.Entry(purchaseOrder).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PurchaseOrderExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
예제 #2
0
        public async Task<IHttpActionResult> PostPurchaseOrder(PurchaseOrder purchaseOrder)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }
            purchaseOrder.Creater = this.RequestContext.Principal.Identity.Name;
            new PurchaseMgrAppService(db).CreaterPurchaseOrder(purchaseOrder);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (PurchaseOrderExists(purchaseOrder.ID))
                {
                    return Conflict();
                }
                else
                {
                    throw;
                }
            }

            return CreatedAtRoute("DefaultApi", new { id = purchaseOrder.ID }, purchaseOrder);
        }
예제 #3
0
        public void UpdatePurchaseVoucher(PurchaseOrder order)
        {
            var existingOrder = db.PurchaseOrders.Find(order.ID);
            if (existingOrder != null)
            {
                db.Entry(existingOrder).CurrentValues.SetValues(order);

            }
        }