public void Save(AssetTypeViewModel assetTypeViewModel)
 {
     AssetType assetType = new AssetType(assetTypeViewModel.Id)
     {
         Name=assetTypeViewModel.Name,
         Description=assetTypeViewModel.Description
     };
     _assetTypeRepository.Save(assetType);
 }
예제 #2
0
 public ActionResult EditAssetType(AssetTypeViewModel atvm) 
 {
     try
     {
         _assetTypeViewModelBuilder.Save(atvm);
         _auditLogViewModelBuilder.AddAuditLog(this.User.Identity.Name, "Edit", "Asset Type", DateTime.Now);
         TempData["msg"] = "Asset Type Successfully Edited";
         return RedirectToAction("ListAssetTypes");
     }
     catch (DomainValidationException dve)
     {
         ValidationSummary.DomainValidationErrors(dve, ModelState);
         return View();
     }
     catch (Exception ex)
     {
         _log.Debug("Failed to edit asset type" + ex.Message);
         _log.Error("Failed to edit asset type" + ex.ToString());
         return View();
     }
 }
예제 #3
0
        public ActionResult CreateAssetType(AssetTypeViewModel atvm) 
        {
            try
            {
                atvm.Id = Guid.NewGuid();
                _assetTypeViewModelBuilder.Save(atvm);
                _auditLogViewModelBuilder.AddAuditLog(this.User.Identity.Name, "Create", "AssetType", DateTime.Now);
                TempData["msg"] = "Asset Type Successfully Created";
                return RedirectToAction("ListAssetTypes");
            }
            catch (DomainValidationException dve)
            {
                ValidationSummary.DomainValidationErrors(dve, ModelState);
                //ViewBag.msg = dve.Message;
                return View();
            }
            catch (Exception ex)
            {
                ViewBag.msg = ex.Message;
                return View();
            }

        }