public ActionResult Save(AssetsDisposalData assetsDT) { if (!ModelState.IsValid) { var viewModel = new AssetsDisposalDataViewModel(assetsDT) { FixedAssets = _context.FixedAssets.ToList() }; return(View("DisposalData", viewModel)); } if (assetsDT.Id == 0) { assetsDT.DisposalDate = DateTime.Now; _context.AssetsDisposalDatas.Add(assetsDT); } else { var assetsDTInDb = _context.AssetsDisposalDatas.Single(m => m.Id == assetsDT.Id); assetsDTInDb.FixedAssetId = assetsDT.FixedAssetId; assetsDTInDb.DisposedValue = assetsDT.DisposedValue; assetsDTInDb.DisposalDate = assetsDT.DisposalDate; assetsDTInDb.Recipient = assetsDT.Recipient; assetsDTInDb.Address = assetsDT.Address; assetsDTInDb.Contact = assetsDT.Contact; } _context.SaveChanges(); return(RedirectToAction("DisposalData", "ADT")); }
// // GET: /AMD/ public ActionResult DisposalData() { var fixedAssets = _context.FixedAssets.ToList(); var assetsDisposalData = _context.AssetsDisposalDatas.ToList(); var viewModel = new AssetsDisposalDataViewModel { AssetsDisposalData = new AssetsDisposalData(), FixedAssets = fixedAssets }; return(View("DisposalData", viewModel)); }
public ActionResult EditAssetsDT(int id) { var adT = _context.AssetsDisposalDatas.SingleOrDefault(a => a.Id == id); if (adT == null) { return(HttpNotFound()); } var viewModel = new AssetsDisposalDataViewModel { AssetsDisposalData = adT, FixedAssets = _context.FixedAssets.ToList(), AssetsDisposalDatas = _context.AssetsDisposalDatas.ToList() }; return(View("DisposalData", viewModel)); }