예제 #1
0
        public ActionResult Edit(int billNo, [FromBody] BillCreateJsonModel modelJson)
        {
            var url = "";

            try
            {
                var model = modelJson;
                if (billNo > 0 && ModelState.IsValid && model != null && model.CustomerId >= 0)
                {
                    var billItems = model.Items.Select(b => GetBillingItem(b)).ToList();
                    var bill      = GetBill(model);
                    bill.BillId = billNo;
                    var billno = _billingContext.UpdateBill(bill, billItems);

                    url = Url.Action("Print?billNo=" + billno);
                    return(new JsonResult(new Dictionary <string, string>()
                    {
                        { "RedirectURL", url }
                    }));
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            throw new Exception(" Model state is invlaid or invalid inputs!");
        }
예제 #2
0
 private Bill GetBill(BillCreateJsonModel billViewModel)
 {
     return(new Bill
     {
         Date = billViewModel.BillDate,
         OutStandingAmount = billViewModel.Items.Sum(t => t.TotalPrice),
         Shop = _billingContext.GetCustomer(billViewModel.CustomerId),
         TotalQuantity = billViewModel.Items.Sum(i => i.Quantity),
         TotalPrice = billViewModel.Items.Sum(t => t.TotalPrice),
         ShopCustomerId = billViewModel.CustomerId,
     });
 }