public ActionResult Entry(AssetEntryVm assetEntryVm)
        {
            ViewBag.orglist = generalCategoryManager.GetAll();

            ViewBag.assetlist = assetManager.GetSome(5);

            var assetCodeCheck = assetManager.GetAll().Where(c => c.Code == assetEntryVm.Code).ToList();

            if (!ModelState.IsValid)
            {
                return(View(assetEntryVm));
            }
            else if (assetCodeCheck.Count > 0)
            {
                ViewBag.msg = "Code Already Exist";
                return(View(assetEntryVm));
            }
            else
            {
                var assetEntry = Mapper.Map <Asset>(assetEntryVm);
                assetEntry.Registered   = false;
                assetEntry.Organization = Session["organizationName"].ToString();
                assetManager.Add(assetEntry);

                //var newAssetEntry = Mapper.Map<NewAsset>(assetEntryVm);
                //newAssetManager.Add(newAssetEntry);

                ModelState.Clear();
                return(RedirectToAction("Entry", new { success = "true" }));
            }
        }
        public async Task <IViewComponentResult> InvokeAsync(int id)
        {
            List <Asset> listOfAssets = null;

            if (id == 0)
            {
                listOfAssets = _assetManager.GetAll();
            }
            else
            {
                listOfAssets = _assetManager.GetAllByAssetType(id);
            }

            var assets = listOfAssets.Select(a => new AssetViewModel
            {
                Description  = a.Description,
                Manufacturer = a.Manufacturer.Name,
                AssetType    = a.AssetType.Name,
                TagNumber    = a.TagNumber,
                SerialNumber = a.SerialNumber,
                Id           = a.Id,
            }).ToList();

            return(View(assets));
        }
        // GET: Asset
        public ActionResult Index()
        {
            var assets     = _assetManager.GetAll();
            var viewModels = assets.Select(a => new AssetViewModel
            {
                Id           = a.Id,
                Description  = a.Description,
                Manufacturer = a.Manufacturer.Name,
                AssetType    = a.AssetType.Name,
                TagNumber    = a.TagNumber,
                SerialNumber = a.SerialNumber,
            }).ToList();

            //call a local service to get collection of assets as the viewmodel
            return(View(viewModels));
        }
예제 #4
0
 public Task <IEnumerable <Asset> > GetAll()
 {
     return(WithConnection((connection, transaction) => _assetManager.GetAll(connection, transaction)));
 }
        // GET: Assets
        public ActionResult Index()
        {
            var asset = _assetManager.GetAll();

            return(View(asset.ToList()));
        }