public ActionResult Withdraw(PartsWithdrawHistoryViewModel model) { if (!ModelState.IsValid) { model.Heading = "Withdraw Parts"; model.Parts = _unitOfWork.Parts.GetAllParts(); return(View(model)); } var _partsSaleHistory = new PartsWithdrawHistory { PartsId = model.PartsId, SoldDate = DateTime.Now, WithdrawlReason = model.WithdrawlReason, QtyWithdrawn = model.QtyWithdrawn, SoldPrice = model.SoldPrice }; _unitOfWork.PartsWithdrawHistories.AddPartWithdrawl(_partsSaleHistory); var _inventory = _unitOfWork.Inventory.GetInventoryByPartsId(model.PartsId); if (_inventory != null) { _inventory.DeleteStockQuantity(model.PartsId, model.QtyWithdrawn, DateTime.Now); } _unitOfWork.Complete(); return(RedirectToAction("WithdrawlHistory", "PartsWithdrawHistories")); }
public IHttpActionResult Delete(int id) { PartsWithdrawHistory _history = _unitOfWork.PartsWithdrawHistories.GetPartsWithdrawlByWithdrawalId(id); Inventory _inventory = _unitOfWork.Inventory.GetInventoryByPartsId(_history.PartsId); _unitOfWork.PartsWithdrawHistories.DeletePartsWithDrawHistoryById(id); if (_inventory != null) { _inventory.AddStockQuantity(_history.PartsId, _history.QtyWithdrawn, DateTime.Now); } _unitOfWork.Complete(); return(Ok()); }
public ActionResult Edit(int id) { PartsWithdrawHistory _histoy = _unitOfWork.PartsWithdrawHistories.GetPartsWithdrawlByWithdrawalId(id); var viewModel = new PartsWithdrawHistoryViewModel { Id = _histoy.Id, Parts = _unitOfWork.Parts.GetAllPartsExcludeDeleted(), PartsId = _histoy.PartsId, QtyWithdrawn = _histoy.QtyWithdrawn, SoldDate = _histoy.SoldDate, SoldPrice = _histoy.SoldPrice, WithdrawlReason = _histoy.WithdrawlReason }; return(View("Withdraw", viewModel)); }
public void AddPartWithdrawl(PartsWithdrawHistory _partsSaleHistory) { _context.PartsWithdrawlHistory.Add(_partsSaleHistory); }