public ActionResult Sales(PartsSaleHistoryViewModel model) { if (!ModelState.IsValid) { model.Parts = _unitOfWork.Parts.GetAllParts(); return(View(model)); } var _partsSaleHistory = new PartsSaleHistory { PartsId = model.PartsId, SoldDate = DateTime.Now, WithdrawlReason = model.WithdrawlReason, QtyWithdrawn = model.QtyWithdrawn, SoldPrice = model.SoldPrice }; _unitOfWork.PartsSaleHistories.AddPartWithdrawl(_partsSaleHistory); var _inventory = _unitOfWork.Inventory.GetInventoryByPartsId(model.PartsId); if (_inventory != null) { _inventory.DeleteStockQuantity(model.PartsId, model.QtyWithdrawn, DateTime.Now); } _unitOfWork.Complete(); return(RedirectToAction("PartsSalesList", "PartsSaleHistories")); }
public ActionResult Sales() { var _partsSalesHistory = new PartsSaleHistoryViewModel { Parts = _unitOfWork.Parts.GetAllParts() }; return(View(_partsSalesHistory)); }