public ActionResult SaveLostProduct(int itemId, int qnty) { if (qnty > 0) { LostProduct lp = new LostProduct(); lp.ItemID = itemId; if (qnty > 0) { lp.LostQnty = qnty; var ckItem = db.Items.FirstOrDefault(i => i.ItemID == itemId); if (ckItem != null) { if (qnty < ckItem.AvailableQnty) { ckItem.AvailableQnty -= qnty; db.Entry(ckItem).State = EntityState.Modified; db.SaveChanges(); } } } lp.OutletID = Convert.ToInt32(Session["OutletID"].ToString()); lp.AddedBy = HttpContext.User.Identity.Name; lp.AddedDate = DateTime.Now; lp.IsDeleted = false; db.LostProducts.Add(lp); db.SaveChanges(); return(Json(true, JsonRequestBehavior.AllowGet)); } else { return(Json(false, JsonRequestBehavior.AllowGet)); } }
public void Insert(LostProduct lostProduct) { var param = new List <SqlParameter> { new SqlParameter("TransactionDetailID", lostProduct.TransactionDetailID), new SqlParameter("@LostQuantity ", lostProduct.LostQuantity), new SqlParameter("@Comment", lostProduct.Comment), }; Insert(param.ToArray()); }
public void Insert(LostProduct lostProduct) { _repository.Insert(lostProduct); }