public async Task <IActionResult> Index(string paramStatus, string token, string sortOrder, string currentFilter, string searchString, int?pageNumber)
        {
            try
            {
                ViewData["CurrentSort"]  = sortOrder;
                ViewData["NameSortParm"] = String.IsNullOrEmpty(sortOrder) ? "HostName" : "";
                ViewData["DateSortParm"] = sortOrder == "AssetNo" ? "ExpressCode" : "AssetNo";

                if (searchString != null)
                {
                    pageNumber = 1;
                }
                else
                {
                    searchString = currentFilter;
                }

                var listUserStaff = new List <UserStaffDTO>();

                listUserStaff = await _userStaffInterface.GetUserStaffs(Request.Cookies["AssetReference"].ToString());

                var model = listUserStaff.AsQueryable();

                if (!String.IsNullOrEmpty(searchString))
                {
                    model = listUserStaff.AsQueryable().Where(x => x.DisplayName.Contains(searchString) || x.Department.Equals(searchString) || x.Location.Equals(searchString));
                }

                switch (sortOrder)
                {
                case "DisplayName":
                    model = model.OrderByDescending(s => s.DisplayName);
                    break;

                case "Department":
                    model = model.OrderByDescending(s => s.Department);
                    break;

                case "Location":
                    model = model.OrderByDescending(s => s.Location);
                    break;

                default:
                    model = model.OrderBy(s => s.DisplayName);
                    break;
                }

                int pageSize = 10;
                return(View(await PaginatedList <UserStaffDTO> .CreateAsync(model.AsNoTracking(), pageNumber ?? 1, pageSize)));
            }
            catch (Exception ex)
            {
                _logger.LogError($"Error encountered in UserStaffsController||Index ErrorMessage: {ex.Message}");
                return(RedirectToAction("Index", "Error"));
            }
        }
        public async Task <IActionResult> AssignAssetsUsers(string assetId)
        {
            try
            {
                var asset = await _assetInterface.GetAsset(assetId, Request.Cookies["AssetReference"].ToString());

                if (asset == null)
                {
                    return(RedirectToAction("Index", "Error"));
                }

                var user = await _userStaffInterface.GetUserStaffs(Request.Cookies["AssetReference"].ToString());

                if (user == null)
                {
                    return(RedirectToAction("Index", "Error"));
                }

                //Map the objects results to corresponding DTO's
                AssetsDTO           assetsDTO    = _mapper.Map <AssetsDTO>(asset);
                List <UserStaffDTO> userStaffDTO = _mapper.Map <List <UserStaffDTO> >(user);

                //Instantiate AssetsUserVIewModel
                var assetsUserVIewModel = new AssetsUserVIewModel()
                {
                    AssetsDTO     = assetsDTO,
                    UserStaffDTOs = userStaffDTO
                };

                //Set the Date to its initial value
                var date = DateTime.Now;
                ViewBag.Date = date.ToString("yyyy-MM-dd");

                ViewBag.AssetId = assetsUserVIewModel.AssetsDTO.Id;

                return(View(assetsUserVIewModel));
            }
            catch (Exception ex)
            {
                _logger.LogError($"Error encountered in AssetsController||AssignAssetsUsers ErrorMessage: {ex.Message}");
                return(RedirectToAction("Index", "Error"));
            }
        }
        public async Task <IActionResult> AssignLicenseUser(string licenseId)
        {
            try
            {
                var license = await _licenseInterface.GetLicense(licenseId, Request.Cookies["AssetReference"].ToString());

                if (license == null)
                {
                    return(RedirectToAction("Index", "Error"));
                }

                var user = await _userStaffInterface.GetUserStaffs(Request.Cookies["AssetReference"].ToString());

                if (user == null)
                {
                    return(RedirectToAction("Index", "Error"));
                }

                //Map the objects results to corresponding DTO's
                LicenseDTO          licenseDTO   = _mapper.Map <LicenseDTO>(license);
                List <UserStaffDTO> userStaffDTO = _mapper.Map <List <UserStaffDTO> >(user);

                //Instantiate LicenseUserViewModel
                var licenseUserViewModel = new LicenseUserViewModel()
                {
                    LicenseDTO    = licenseDTO,
                    UserStaffDTOs = userStaffDTO
                };

                //Set the Date to its initial value
                var date = DateTime.Now;
                ViewBag.Date = date.ToString("yyyy-MM-dd");

                ViewBag.LicenseId = licenseUserViewModel.LicenseDTO.Id;

                return(View(licenseUserViewModel));
            }
            catch (Exception ex)
            {
                _logger.LogError($"Error encountered in LicenseController||AssignLicenseUser ErrorMessage: {ex.Message}");
                return(RedirectToAction("Index", "Error"));
            }
        }
        public async Task <IViewComponentResult> InvokeAsync()
        {
            var result = await _userStaffInterface.GetUserStaffs(Request.Cookies["AssetReference"].ToString());

            //Map the objects results to corresponding DTO's
            IEnumerable <UserStaffDTO> userStaffDTOs = _mapper.Map <IEnumerable <UserStaffDTO> >(result);

            ViewBag.TotaUserStaffCount = userStaffDTOs.ToList().Count();

            return(View(userStaffDTOs));
        }