Example #1
0
        public async Task <IHttpActionResult> PostPurchase(string[] transnos)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var xPreData = _SVC.LookupOrder(new OrderQueryViewModel()
            {
                TransNos = transnos.ToList()
            });
            Purchase purchase = new Purchase()
            {
                TradeDate = DateTime.Today
            };

            try
            {
                await _SVC.AddPurchase(purchase, xPreData);
            }
            catch (DbUpdateException)
            {
                if (PurchaseExists(purchase.TransNo))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = purchase.TransNo }, purchase));
        }
 async public Task <ActionResult> Add(Purchase item)
 {
     return(Content(await _Service.AddPurchase(item, TempData["ReadyPurchase"] as IEnumerable <Order>)));
 }