public ActionResult Save(AssetsTransferData assetsTD) { if (!ModelState.IsValid) { var viewModel = new AssetsTransferDataViewModel(assetsTD) { FixedAssets = _context.FixedAssets.ToList() //Locations = _context.Locations.ToList(), //Branches = _context.Branches.ToList(), //Companies = _context.Companies.ToList() }; return(View("ValuationDetails", viewModel)); } if (assetsTD.Id == 0) { assetsTD.TransferDate = DateTime.Now; _context.AssetsTransferDatas.Add(assetsTD); } else { var assetsTDInDb = _context.AssetsTransferDatas.Single(m => m.Id == assetsTD.Id); assetsTDInDb.FixedAssetId = assetsTD.FixedAssetId; assetsTDInDb.NewBranch = assetsTD.NewBranch; assetsTDInDb.NewCompany = assetsTD.NewCompany; assetsTDInDb.NewLocation = assetsTD.NewLocation; assetsTDInDb.TransferDate = assetsTD.TransferDate; } _context.SaveChanges(); return(RedirectToAction("TransferData", "ATD")); }
public ActionResult EditAssetsTD(int id) { var atd = _context.AssetsTransferDatas.SingleOrDefault(a => a.Id == id); if (atd == null) { return(HttpNotFound()); } var viewModel = new AssetsTransferDataViewModel { AssetsTransferData = atd, FixedAssets = _context.FixedAssets.ToList(), AssetsTransferDatas = _context.AssetsTransferDatas.ToList() }; return(View("TransferData", viewModel)); }
public ActionResult TransferData() { var fixedAssets = _context.FixedAssets.ToList(); //var locations = _context.Locations.ToList(); //var branches = _context.Branches.ToList(); //var companies = _context.Companies.ToList(); var assetsTransferData = _context.AssetsTransferDatas.ToList(); var viewModel = new AssetsTransferDataViewModel { AssetsTransferData = new AssetsTransferData(), FixedAssets = fixedAssets //Locations = locations, //Branches = branches, //Companies = companies }; return(View("TransferData", viewModel)); }