protected IEnumerable GetAssetTypes()
        {
            var types = AssetTypeManager.GetAsKeyValuePairs();
            var list  = new SelectList(types, "Value", "Text");

            return(list);
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,TagNumber,AssetTypeId,Manufacturer,Model,Description,SerialNumber")] Asset asset)
        {
            if (id != asset.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    AssetManager.Update(asset);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AssetExists(asset.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AssetTypeId"] = new SelectList(AssetTypeManager.GetAll(), "Id", "Name", asset.AssetTypeId);
            return(View(asset));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] AssetType assetType)
        {
            if (id != assetType.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    AssetTypeManager.Update(assetType);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AssetTypeExists(assetType.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(assetType));
        }
Ejemplo n.º 4
0
 //Creating new asset
 public IActionResult Create()
 {
     var aType = AssetTypeManager.GetAsKeyValuePairs();
     var list = new SelectList(aType, "Value", "Text");
     ViewBag.AssetTypeId = list; //Different then GetAssetTypes (I did not want it to show "All" on index 0 while adding new assets)
     return View();
 }
        protected override void Grid_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            if (e.CommandName == "add")
            {
                TextBox  NewNameTextBox       = (TextBox)e.Item.FindControl("NewNameTextBox");
                CheckBox NewIsVisibleCheckBox = (CheckBox)e.Item.FindControl("NewIsVisibleCheckBox");

                try
                {
                    AssetType assetType = AssetType.New();
                    assetType.Name      = NewNameTextBox.Text.Trim();
                    assetType.IsVisible = NewIsVisibleCheckBox.Checked;
                    AssetTypeManager.SaveAssetType(assetType);

                    AuditLogManager.LogUserAction(CurrentUser, AuditUserAction.AddAssetType, string.Format("Added Asset Type: {0}, AssetTypeId: {1}", assetType.Name, assetType.AssetTypeId));

                    ResetGridState();
                    MessageLabel1.SetSuccessMessage("Asset type added successfully");
                }
                catch (InvalidAssetTypeException imtex)
                {
                    MessageLabel1.SetErrorMessage("Unable to add asset type", imtex.Errors);
                    BindGrid(CurrentPage);
                }
            }
        }
Ejemplo n.º 6
0
        // GET: Assets/Create
        public ActionResult Create()
        {
            // Populate dropdown boxes for asset type
            var AssetTypes = AssetTypeManager.GetAsKeyValuePairs();

            ViewBag.AssetTypes = new SelectList(AssetTypes, "Id", "Name");
            return(View());
        }
Ejemplo n.º 7
0
        public IActionResult Create()
        {
            var types = AssetTypeManager.GetAsKeyValuePairs();
            var list  = new SelectList(types, "Value", "Text");

            ViewBag.AssetTypes = list;
            return(View());
        }
Ejemplo n.º 8
0
        protected IList NoIndexAssetTypes()
        {
            // create collection of property types and assign as key value pairs
            var keyValueTypes   = AssetTypeManager.GetAsKeyValuePairs();
            var selectListTypes = new SelectList(keyValueTypes, "Value", "Text");
            var listTypes       = selectListTypes.ToList();

            return(listTypes);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// AddAsset page routing.
        /// </summary>
        /// <returns>Renders view of the page used to add new assets.</returns>
        public IActionResult AddAsset()
        {
            //Retrieves all assets types from AssetType table and adds to ViewBag to share with the view.
            var assetTypes = AssetTypeManager.GetAllAssetTypes();

            ViewBag.AssetTypes = assetTypes;

            return(View());
        }
        // GET: AssetTypes
        public ActionResult Index()
        {
            var assetTypes = AssetTypeManager.GetAll().
                             Select(at => new AssetTypesViewModel
            {
                Id       = at.Id,
                TypeName = at.Name,
            }).ToList();

            return(View(assetTypes));
        }
Ejemplo n.º 11
0
        // GET: Asset/Details/5
        //public ActionResult Details(int id)
        //{
        //    return View();
        //}

        // GET: Asset/Create
        public ActionResult Create()
        {
            //get Asset type from AssetTypeManager.  This will populate the dropdown list in the Create page
            var assetTypes = AssetTypeManager.GetAsKeyValuePairs();
            var list       = new SelectList(assetTypes, "Id", "Name");

            ViewBag.AssetTypeId = list;


            return(View());
        }
        // GET: AssetType/Delete/5
        public ActionResult Delete(int id)
        {
            var assetType      = AssetTypeManager.GetAssetTypeById(id);
            var assetTypeModel = new AssetTypeModel
            {
                Id   = assetType.Id,
                Name = assetType.Name
            };

            return(View(assetTypeModel));
        }
        public IActionResult Index()
        {
            var type      = AssetTypeManager.GetAll();
            var viewModel = type.Select(t => new AssetTypeViewModel
            {
                Id   = t.Id,
                Name = t.Name
            }).ToList();

            return(View(viewModel));
        }
 public AssetEntriesController()
 {
     _assetEntryManager       = new AssetEntryManager();
     _organizationManager     = new OrganizationManager();
     _branchManager           = new BranchManager();
     _assetLocationManager    = new AssetLocationManager();
     _assetTypeManager        = new AssetTypeManager();
     _assetGroupManager       = new AssetGroupManager();
     _assetManufactureManager = new AssetManufactureManager();
     _assetModelManager       = new AssetModelManager();
 }
Ejemplo n.º 15
0
 public IActionResult AddAssetType(AssetType assetType)
 {
     try
     {
         AssetTypeManager.AddAssetType(assetType);   //Attempts to add new record.
         return(RedirectToAction("Index", "Asset")); //Attempts to redirect to index of AssetController.
     }
     catch
     {
         return(View());
     }
 }
Ejemplo n.º 16
0
 public ActionResult Create(AssetType type)
 {
     try
     {
         AssetTypeManager.AddNewType(type);
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
Ejemplo n.º 17
0
 public IActionResult Create(AssetType assetType)
 {
     try
     {
         AssetTypeManager.Add(assetType);
         return(RedirectToAction("Create", "Asset"));
     }
     catch
     {
         return(View());
     }
 }
Ejemplo n.º 18
0
 public IActionResult Create(AssetType assetType)
 {
     try
     {
         AssetTypeManager.Add(assetType);
         return(Redirect("/Successful.html"));
     }
     catch
     {
         return(View());
     }
 }
 public ActionResult Edit(int id, AssetType assetType)
 {
     try
     {
         AssetTypeManager.UpdateAssetType(assetType);
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
Ejemplo n.º 20
0
        /// <summary>
        /// Edit page routing.
        /// </summary>
        /// <param name="id">The Asset Id of the record that the user wants to modify.</param>
        /// <returns>Redirects user edit page with information from the selected record populated.</returns>
        public IActionResult Edit(int id)
        {
            //Retrieves all assets types from AssetType table and adds to ViewBag to share with the view.
            var assetTypes = AssetTypeManager.GetAllAssetTypes();

            ViewBag.AssetTypes = assetTypes;

            //Retrieves the information associated with the currently selected asset record.
            var currentAsset = AssetManager.Find(id);

            return(View(currentAsset));
        }
Ejemplo n.º 21
0
 public IActionResult Create(AssetType asset)
 {
     try
     {
         AssetTypeManager.Add(asset);       // call the add method from manager
         return(RedirectToAction("Index")); //redirect back to list of asset types
     }
     catch
     {
         return(View());
     }
 }
 public IActionResult Create(AssetType type)
 {
     try
     {
         AssetTypeManager.Add(type);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Ejemplo n.º 23
0
        public IActionResult Index()
        {
            var filters = new AssetSearchViewModel();

            filters.Types = AssetTypeManager.GetAll().Select(t =>
                                                             new SelectListItem
            {
                Text  = t.Name,
                Value = t.Id.ToString()
            });
            return(View(filters));
        }
        //To be used only for dropdown on home page. it has All Types Selection
        protected IEnumerable GetAssetTypes()
        {
            var types                = AssetTypeManager.GetAsKeyValuePairs();
            var typeList             = new SelectList(types, "Value", "Text");
            var typeListWithAllTypes = typeList.ToList();

            typeListWithAllTypes.Insert(0, new SelectListItem
            {
                Text  = "All Types",
                Value = "0"
            });
            return(typeListWithAllTypes);
        }
Ejemplo n.º 25
0
        //method to create the view for the asset types
        public IActionResult Index()
        {
            //call to the assets types manager class to get a list of all asset types
            //and create a new asset type view model
            var assets     = AssetTypeManager.GetAll();
            var viewModels = assets.Select(a => new AssetTypeViewModel
            {
                Name = a.Name
            })
                             .ToList();

            return(View(viewModels));
        }
Ejemplo n.º 26
0
        // GET: Assignment
        public async Task <ActionResult> Index()
        {
            HttpResponseMessage msg = await ClientEmployee.GetAsync(URLemployees);

            var employees = new List <Employee>();

            if (msg.IsSuccessStatusCode)
            {
                var data = msg.Content.ReadAsStringAsync().Result;
                employees = JsonConvert.DeserializeObject <List <Employee> >(data); //employee data
            }

            AssetTypeManager TypeMng = new AssetTypeManager();
            var Types = TypeMng.GetAssetTypes(); //get asset types

            AssetManager AssetMng = new AssetManager();
            var          Assets   = AssetMng.GetAssets(); //get all assets

            var UnassignedEmployee = employees            //Collection of employee who haven't been assigned any asset
                                     .Where(o => Assets.All(a => o.EmployeeNumber != a.AssignedTo))
                                     .Select(o => new Employee
            {
                Id             = o.Id,
                EmployeeNumber = o.EmployeeNumber,
                FirstName      = o.FirstName,
                LastName       = o.LastName,
                Position       = o.Position,
                Phone          = o.Phone,
                DepartmentId   = o.DepartmentId
            }).ToList();

            var assetTypeList = new List <SelectListItem>();

            foreach (var type in Types)
            {
                assetTypeList.Add(new SelectListItem {
                    Value = type.Id.ToString(), Text = type.Name
                });
            }

            var employeesList = UnassignedEmployee.Select(o => new SelectListItem {
                Value = o.EmployeeNumber, Text = $"{o.FirstName} {o.LastName} (Phone: {o.Phone})"
            });

            AssignmentViewModel ViewModel = new AssignmentViewModel();

            ViewModel.AssetType           = assetTypeList;
            ViewModel.UnassignedEmployees = employeesList;

            return(View(ViewModel));
        }
Ejemplo n.º 27
0
        // GET: Assets
        public async Task <IActionResult> Index()
        {
            var assetTypes = AssetTypeManager.GetAll();
            List <SelectListItem> items = new SelectList(assetTypes, "Id", "Name").ToList();

            items.Insert(0, (new SelectListItem {
                Text = "ALL", Value = null
            }));
            ViewBag.AssetTypes = items;

            var assets = AssetManager.GetAll().ToList();

            return(View(assets));
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Index page routing.
        /// </summary>
        /// <returns>Renders the view of the index.</returns>
        public IActionResult Index()
        {
            //Retrieves all assets types from AssetType table.
            var assetTypes = AssetTypeManager.GetAllAssetTypes();

            //Adds a new AssetType at index 0 with an Id of 0 so that we can show all AssetTypes.
            assetTypes.Insert(0, new Domain.AssetType {
                Id = 0, Name = "All Types"
            });

            //Stores information in a ViewBag to be shared with the view.
            ViewBag.AssetTypes = assetTypes;
            return(View());
        }
        public ActionResult Create(AssetType assetType)
        {
            try
            {
                // call the Method to add an assetType - see AssetType manager class
                AssetTypeManager.Add(assetType);

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
Ejemplo n.º 30
0
        public IActionResult Index()
        {
            var types      = AssetTypeManager.GetAsKeyValuePairs();
            var assetTypes = new SelectList(types, "Value", "Text");
            var list       = assetTypes.ToList();

            list.Insert(0, new SelectListItem
            {
                Text  = "All Types",
                Value = "0"
            });
            ViewBag.AssetTypes = list;
            return(View());
        }