public ActionResult Edit([Form] SalesInvoice s1)
 {
     if (ModelState.IsValid)
     {
         s1.Update();
         return(RedirectToAction("Index"));
     }
     else
     {
         ViewBag.itypes = InvoiceType.get();
         ViewBag.loc    = Location.GetLocations();
         ViewBag.party  = party.Getparties();
         ViewBag.items  = Item.Get();
         return(View(SalesInvoice.GetSaleInvoice(s1.SaleInvoiceId)));
     }
     //return View();
 }
        public async Task <ActionResult> Edit(int?id)
        {
            if (!id.HasValue)
            {
                return(RedirectToAction("Index"));
            }
            SalesInvoice temp = null;

            ViewBag.id = id.Value;
            await Task.Run(() =>
            {
                ViewBag.itypes = InvoiceType.get();
                ViewBag.loc    = Location.GetLocations();
                ViewBag.party  = party.Getparties();
                ViewBag.items  = Item.Get();

                temp = SalesInvoice.GetSaleInvoice(id.Value);
            });

            return(View(temp));
        }