public async Task <IHttpActionResult> PostReceipt(string[] transnos)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var xPreData = _SVC.LookupOrder(new OrderQueryViewModel()
            {
                TransNos = transnos.ToList()
            });
            Receipt receipt = new Receipt()
            {
                TradeDate = DateTime.Today, TradeAmount = xPreData.Sum(s => s.TradeAmount)
            };

            try
            {
                await _SVC.AddReceipt(receipt, xPreData);
            }
            catch (DbUpdateException)
            {
                if (ReceiptExists(receipt.TransNo))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = receipt.TransNo }, receipt));
        }
Exemplo n.º 2
0
 async public Task <ActionResult> Add(Receipt item)
 {
     return(Content(await _Service.AddReceipt(item, TempData["ReadyPay"] as IEnumerable <Order>)));
 }