public ActionResult Edit([Bind(Include = "ID,Date,Amount,Discount,Tax,GrandTotal,UserID,Remarks")] DataAccess.Sale sales) { if (ModelState.IsValid) { var original = salRepo.GetAll().ToList().Find(x => x.ID == sales.ID); salRepo.Update(original, sales); // db.Entry(sales).State = EntityState.Modified; // db.SaveChanges(); return(RedirectToAction("Index")); } return(View(sales)); }
public JsonResult SerializeFormData(FormCollection _collection, string Total, string Discount, string GrandTotal) { if (_collection != null) { string[] _stockID, _qty, _rate, _amt; //for salesItem _stockID = _collection["StockID"].Split(','); _qty = _collection["Qty"].Split(','); _rate = _collection["Rate"].Split(','); _amt = _collection["Amount"].Split(','); //for sales decimal _total = Convert.ToDecimal(Total); decimal _discount = Convert.ToDecimal(Discount); decimal _grandTotal = Convert.ToDecimal(GrandTotal); DateTime _date = DateTime.Now; //instance of the global class // MvcApplication app = new MvcApplication(); DataAccess.Sale _sales = new DataAccess.Sale() { Date = _date, Amount = _total, Discount = _discount, GrandTotal = _grandTotal, Tax = 0, SaleUser = User.Identity.Name, Remarks = "-" }; //insert into sales, sales-items, stock int salesID = slsrepo.InsertSales(_sales); slsrepo.InsertSalesItem(salesID, _stockID, _qty, _rate, _amt); slsrepo.UpdateStock(_stockID, _qty); return(Json(salesID)); } return(Json("null")); }