public ActionResult Save(AssetsMaintenanceDetails assetsMD) { if (!ModelState.IsValid) { var viewModel = new AssetsMaintenanceViewModel(assetsMD) { FixedAssets = _context.FixedAssets.ToList() }; return(View("MaintenanceDetails", viewModel)); } if (assetsMD.Id == 0) { assetsMD.TransactionDate = DateTime.Now; _context.AssetsMaintenanceDetails.Add(assetsMD); } else { var assetsMDInDb = _context.AssetsMaintenanceDetails.Single(m => m.Id == assetsMD.Id); assetsMDInDb.FixedAssetId = assetsMD.FixedAssetId; assetsMDInDb.MaintenanceSupervisor = assetsMD.MaintenanceSupervisor; assetsMDInDb.TransactionDate = assetsMD.TransactionDate; assetsMDInDb.Amount = assetsMD.Amount; assetsMDInDb.Maint_Description = assetsMD.Maint_Description; assetsMDInDb.GLDebit = assetsMD.GLDebit; assetsMDInDb.GLCredit = assetsMD.GLCredit; } _context.SaveChanges(); return(RedirectToAction("MaintenanceDetails", "AMD")); }
public ActionResult DeleteConfirmed(int id) { AssetsMaintenanceDetails assetsMaintenanceDetails = _context.AssetsMaintenanceDetails.Find(id); _context.AssetsMaintenanceDetails.Remove(assetsMaintenanceDetails); _context.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,FixedAssetId,MaintenanceSupervisor,TransactionDate,Amount,Maint_Description,GLDebit,GLCredit")] AssetsMaintenanceDetails assetsMaintenanceDetails) { if (ModelState.IsValid) { _context.Entry(assetsMaintenanceDetails).State = EntityState.Modified; _context.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.FixedAssetId = new SelectList(_context.FixedAssets, "Id", "Description", assetsMaintenanceDetails.FixedAssetId); return(View(assetsMaintenanceDetails)); }
public AssetsMaintenanceViewModel(AssetsMaintenanceDetails amd) { Id = amd.Id; MaintenanceSupervisor = amd.MaintenanceSupervisor; TransactionDate = amd.TransactionDate; Amount = amd.Amount; Maint_Description = amd.Maint_Description; GLDebit = amd.GLDebit; GLCredit = amd.GLCredit; FixedAssetId = amd.FixedAssetId; }
// GET: AssetsMaintenanceDetails/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } AssetsMaintenanceDetails assetsMaintenanceDetails = _context.AssetsMaintenanceDetails.Include(a => a.FixedAsset).SingleOrDefault(a => a.Id == id); if (assetsMaintenanceDetails == null) { return(HttpNotFound()); } return(View(assetsMaintenanceDetails)); }
// GET: AssetsMaintenanceDetails/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } AssetsMaintenanceDetails assetsMaintenanceDetails = _context.AssetsMaintenanceDetails.Find(id); if (assetsMaintenanceDetails == null) { return(HttpNotFound()); } ViewBag.FixedAssetId = new SelectList(_context.FixedAssets, "Id", "Description", assetsMaintenanceDetails.FixedAssetId); return(View(assetsMaintenanceDetails)); }