public ActionResult SaveNewAsset(FixAssetViewModel assetModel)
        {
            FixAssetModel asset = new FixAssetModel();

            asset.Model        = assetModel.Model;
            asset.SerialNumber = assetModel.SerialNumber;
            asset.AssetTag     = assetModel.AssetTag;
            asset.Brand        = assetModel.Brand;
            asset.Remarks      = assetModel.Remarks;
            if (assetModel.AcquisitionDate != null)
            {
                asset.AcquisitionDate = assetModel.AcquisitionDate;
            }
            if (assetModel.ExpiryDate != null)
            {
                asset.ExpiryDate = assetModel.ExpiryDate;
            }
            if (assetModel.IssuerID != null)
            {
                asset.IssuerID = assetModel.IssuerID;
            }
            if (assetModel.LocationID != null)
            {
                asset.LocationID = assetModel.LocationID;
            }
            asset.AssetTypeID   = assetModel.AssetTypeID;
            asset.AssetStatusID = 2;
            asset.AssetClassID  = assetModel.AssetClassID;
            FixAssetManagementProcess assetManagement = new FixAssetManagementProcess();
            bool success = assetManagement.NewAsset(asset);

            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
        public ActionResult EditAsset(FixAssetViewModel assetModel)
        {
            FixAsset assetToEdit = new FixAsset();

            assetToEdit.AssetTag      = assetModel.AssetTag;
            assetToEdit.FixAssetID    = assetModel.FixAssetID;
            assetToEdit.SerialNumber  = assetModel.SerialNumber;
            assetToEdit.Model         = assetModel.Model;
            assetToEdit.Brand         = assetModel.Brand;
            assetToEdit.AssetClassID  = assetModel.AssetClassID;
            assetToEdit.AssetStatusID = assetModel.AssetStatusID;
            assetToEdit.AssetTypeID   = assetModel.AssetTypeID;
            assetToEdit.IssuerID      = assetModel.IssuerID;
            assetToEdit.LocationID    = assetModel.LocationID;
            assetToEdit.Remarks       = assetModel.Remarks;

            if (assetModel.AcquisitionDate != null)
            {
                assetToEdit.AcquisitionDate = assetModel.AcquisitionDate;
            }

            if (assetModel.ExpiryDate != null)
            {
                assetToEdit.ExpiryDate = assetModel.ExpiryDate;
            }


            AssetProcess assetProcess = new AssetProcess();

            try
            {
                if (assetProcess.Update(assetToEdit) == FASTConstant.RETURN_VAL_SUCCESS)
                {
                    TempData[FASTConstant.TMPDATA_RESULT]       = FASTConstant.SUCCESSFUL;
                    TempData[FASTConstant.TMPDATA_SOURCE]       = "Edit Fix Asset";
                    TempData[FASTConstant.TMPDATA_EXTRAMESSAGE] = "The asset has been successfully modified.";
                    TempData[FASTConstant.TMPDATA_ACTION]       = "Index";
                    TempData[FASTConstant.TMPDATA_CONTROLLER]   = "FixAsset";

                    return(View("~/Views/Shared/Result.cshtml"));
                }
                else
                {
                    throw new Exception("There was an error while adding the new employee.");
                }
            }
            catch (Exception ex)
            {
                TempData[FASTConstant.TMPDATA_RESULT]       = FASTConstant.FAILURE;
                TempData[FASTConstant.TMPDATA_SOURCE]       = "Edit Fix Asset";
                TempData[FASTConstant.TMPDATA_EXTRAMESSAGE] = ex.Message;
                return(View("~/Views/Shared/Result.cshtml"));
            }
        }
Exemplo n.º 3
0
        public ActionResult Create()
        {
            var organisationId = UserOrganisationId;
            var assetClass     = NidanBusinessService.RetrieveAssetClasses(organisationId, e => true);
            var items          = NidanBusinessService.RetrieveItems(organisationId, e => true);
            var centres        = NidanBusinessService.RetrieveCentres(organisationId, e => true);
            var viewModel      = new FixAssetViewModel()
            {
                FixAsset     = new FixAsset(),
                AssetClasses = new SelectList(assetClass, "AssetClassId", "Name"),
                Itemes       = new SelectList(items, "ItemId", "Name"),
                Centres      = new SelectList(centres, "CentreId", "Name")
            };

            return(View(viewModel));
        }
Exemplo n.º 4
0
        public ActionResult EditAsset(string tag)
        {
            AssetProcess assetProcess = new AssetProcess();
            GenericProcess <Location>   locationProcess = new GenericProcess <Location>();
            GenericProcess <Issuer>     issuerProcess   = new GenericProcess <Issuer>();
            GenericProcess <AssetType>  typeProcess     = new GenericProcess <AssetType>();
            GenericProcess <AssetStatu> statusProcess   = new GenericProcess <AssetStatu>();
            GenericProcess <AssetClass> classProcess    = new GenericProcess <AssetClass>();


            string assetTag = tag;

            vwFixAssetList assetToEdit = assetProcess.GetFixAssetByAssetTag(assetTag);

            FixAssetViewModel assetView = new FixAssetViewModel();

            assetView.AssetTag      = assetToEdit.AssetTag;
            assetView.FixAssetID    = assetToEdit.FixAssetID;
            assetView.SerialNumber  = assetToEdit.SerialNumber;
            assetView.Model         = assetToEdit.Model;
            assetView.Brand         = assetToEdit.Brand;
            assetView.AssetClassID  = assetToEdit.AssetClassID;
            assetView.AssetStatusID = assetToEdit.AssetStatusID;
            assetView.AssetTypeID   = assetToEdit.AssetTypeID;
            assetView.IssuerID      = assetToEdit.IssuerID;
            assetView.LocationID    = assetToEdit.LocationID;
            assetView.Remarks       = assetToEdit.Remarks;

            if (assetToEdit.AcquisitionDate != null)
            {
                assetView.AcquisitionDate = assetToEdit.AcquisitionDate;
            }


            if (assetToEdit.ExpiryDate != null)
            {
                assetView.ExpiryDate = assetToEdit.ExpiryDate;
            }

            ViewBag.Location    = locationProcess.GetAll().ToList();
            ViewBag.Issuer      = issuerProcess.GetAll().ToList();
            ViewBag.AssetType   = typeProcess.GetAll().ToList();
            ViewBag.AssetStatus = statusProcess.GetAll().ToList();
            ViewBag.AssetClass  = classProcess.GetAll().ToList();

            return(View(assetView));
        }
Exemplo n.º 5
0
        public ActionResult Create(FixAssetViewModel fixAssetViewModel)
        {
            var organisationId = UserOrganisationId;
            var personnelId    = UserPersonnelId;

            if (ModelState.IsValid)
            {
                fixAssetViewModel.FixAsset.OrganisationId = organisationId;
                fixAssetViewModel.FixAsset.CreatedBy      = personnelId;
                fixAssetViewModel.FixAsset = NidanBusinessService.CreateFixAsset(UserOrganisationId, fixAssetViewModel.FixAsset);
                return(RedirectToAction("Index"));
            }
            fixAssetViewModel.AssetClasses = new SelectList(NidanBusinessService.RetrieveAssetClasses(organisationId, e => true).ToList());
            fixAssetViewModel.Itemes       = new SelectList(NidanBusinessService.RetrieveItems(organisationId, e => true).ToList());
            fixAssetViewModel.Centres      = new SelectList(NidanBusinessService.RetrieveCentres(organisationId, e => true).ToList());
            return(View(fixAssetViewModel));
        }
Exemplo n.º 6
0
        // GET: FixAsset/View/{id}
        public ActionResult View(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var organisationId = UserOrganisationId;
            var fixAsset       = NidanBusinessService.RetrieveFixAsset(organisationId, id.Value, e => true);

            if (fixAsset == null)
            {
                return(HttpNotFound());
            }
            var viewModel = new FixAssetViewModel()
            {
                FixAsset = fixAsset
            };

            return(View(viewModel));
        }