Пример #1
0
 public ActionResult Save(AssetsInspectionDetails assetsInspD)
 {
     if (!ModelState.IsValid)
     {
         var viewModel = new AssetsInspectionDetailViewModel(assetsInspD)
         {
             FixedAssets   = _context.FixedAssets.ToList(),
             AssetStatuses = _context.AssetStatus.ToList()
         };
         return(View("InspectionDetails", viewModel));
     }
     if (assetsInspD.Id == 0)
     {
         assetsInspD.InspectionDate = DateTime.Now;
         _context.AssetsInspectionDetail.Add(assetsInspD);
     }
     else
     {
         var assetsInspDInDb = _context.AssetsInspectionDetail.Single(m => m.Id == assetsInspD.Id);
         assetsInspDInDb.FixedAssetId   = assetsInspD.FixedAsset.Id;
         assetsInspDInDb.InspectionDate = assetsInspD.InspectionDate;
         assetsInspDInDb.InspectedBy    = assetsInspD.InspectedBy;
         assetsInspDInDb.AssetStatus    = assetsInspD.AssetStatus;
         assetsInspDInDb.Remarks        = assetsInspD.Remarks;
     }
     _context.SaveChanges();
     return(RedirectToAction("InspectionDetails", "AINSPD"));
 }
Пример #2
0
        public ActionResult InspectionDetails()
        {
            var fixedAssets = _context.FixedAssets.ToList();
            var assetStatus = _context.AssetStatus.ToList();

            var assetsInspectionDetails = _context.AssetsInspectionDetail.ToList();

            var viewModel = new AssetsInspectionDetailViewModel
            {
                AssetsInspectionDetail = new AssetsInspectionDetails(),
                FixedAssets            = fixedAssets,
                AssetStatuses          = assetStatus
            };

            return(View("InspectionDetails", viewModel));
        }
Пример #3
0
        public ActionResult EditAssetsInspD(int id)
        {
            var aInspD = _context.AssetsInspectionDetail.SingleOrDefault(a => a.Id == id);

            if (aInspD == null)
            {
                return(HttpNotFound());
            }
            var viewModel = new AssetsInspectionDetailViewModel
            {
                AssetsInspectionDetail  = aInspD,
                FixedAssets             = _context.FixedAssets.ToList(),
                AssetsInspectionDetails = _context.AssetsInspectionDetail.ToList()
            };

            return(View("InspectionDetails", viewModel));
        }