コード例 #1
0
 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"));
 }
コード例 #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            AssetsMaintenanceDetails assetsMaintenanceDetails = _context.AssetsMaintenanceDetails.Find(id);

            _context.AssetsMaintenanceDetails.Remove(assetsMaintenanceDetails);
            _context.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #3
0
 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));
 }
コード例 #4
0
 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;
 }
コード例 #5
0
        // 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));
        }
コード例 #6
0
        // 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));
        }