Esempio n. 1
0
        public ActionResult ApproveIndex(int? page, string searchTerm = null)
        {
            int pageNumber = (page ?? 1);
            var auditorList = _context.Users.OrderByDescending(s => s.LastName).
                Where(p => searchTerm == null || p.UserName.StartsWith(searchTerm))
                .Where(p => p.Status != MyEnums.StatusOptions.Approved );
            var indexViewModel = new List<IndexViewModel>();
            foreach (var n in auditorList)
            {
                var mygroup = _repository.Find<Group>(n.GroupId);

                var model = new IndexViewModel
                {
                    Firstname = n.FirstName,
                    UserName = n.UserName,
                    Lastname = n.LastName,
                    Id = n.Id,
                    GroupName = mygroup.Name,
                    Maker = n.Maker,
                    Email = n.Email,
                    Country = n.Country,
                    PhoneNumber = n.PhoneNumber,
                    Cheker = n.Cheker,
                    Enabled = n.Enabled,
                    StatusOptions = n.Status
                };
                indexViewModel.Add(model);
            }
            _getVals.LogAudit(User.Identity.GetUserName(), "Viewed", Request.UserHostName, "Viewed Users Listing ", "ISA", "UserManagement");
            return View(indexViewModel.ToPagedList(pageNumber, PageSize));//.ToPagedList(pageNumber, PageSize)
        }
Esempio n. 2
0
        public ActionResult AccountIndex(int? page, string searchTerm = null, string SelectedColumn = null, string CheckedEnabled = null, string checkedItemRadio=null)
        {
            int pageNumber = (page ?? 1);
            TempData["Column"] = SelectedColumn;
            TempData["searchTerm"] = searchTerm;
            TempData["CheckedEnabled"] = CheckedEnabled;
            TempData["checkedItemRadio"] = checkedItemRadio;
            var userlist = _context.Users.OrderByDescending(s => s.LastLogin).
                    Where(p => searchTerm == null || p.UserName.StartsWith(searchTerm)); 
            if (SelectedColumn == "1")
            {
                userlist = _context.Users.OrderByDescending(s => s.LastLogin).
                    Where(
                        p =>
                            (searchTerm == null || p.UserName.StartsWith(searchTerm)) &&
                            (CheckedEnabled == null || p.Enabled.ToString().StartsWith(CheckedEnabled)) &&
                            (checkedItemRadio == null || p.Status.ToString().StartsWith(checkedItemRadio)));
            }
            if (SelectedColumn == "2")
            {
                userlist = _context.Users.OrderByDescending(s => s.LastLogin).
                Where(
                    p =>
                        (searchTerm == null || p.FirstName.StartsWith(searchTerm)) &&
                        (CheckedEnabled == null || p.Enabled.ToString().StartsWith(CheckedEnabled)) &&
                        (checkedItemRadio == null || p.Status.ToString().StartsWith(checkedItemRadio)));
            }
            if (SelectedColumn == "3")
            {
                userlist = _context.Users.OrderByDescending(s => s.LastLogin).
                Where(
                    p =>
                        (searchTerm == null || p.LastName.StartsWith(searchTerm)) &&
                        (CheckedEnabled == null || p.Enabled.ToString().StartsWith(CheckedEnabled)) &&
                        (checkedItemRadio == null || p.Status.ToString().StartsWith(checkedItemRadio)));
            }
           
            var indexViewModel = new List<IndexViewModel>();
            foreach (var n in userlist)
                {
                    var mygroup = _repository.Find<Group>(n.GroupId);

                    var model = new IndexViewModel
                    {
                        Firstname = n.FirstName,
                        UserName = n.UserName,
                        Lastname = n.LastName,
                        Id = n.Id,
                        GroupName = mygroup.Name,
                        Maker = n.Maker,
                        Email = n.Email,
                        Country = n.Country,
                        PhoneNumber = n.PhoneNumber,
                        Cheker = n.Cheker,
                        Enabled = n.Enabled,
                        StatusOptions = n.Status
                    };
                    indexViewModel.Add(model);
                }
                _getVals.LogAudit(User.Identity.GetUserName(), "Viewed", Request.UserHostName, "Viewed Users Listing ",
                    "ISA", "UserManagement");
                return View(indexViewModel.ToPagedList(pageNumber, PageSize)); //.ToPagedList(pageNumber, PageSize)
            

            
                //var auditorList = _context.Users.OrderByDescending(s => s.Status).
                //    Where(p => searchTerm == null || p.UserName.StartsWith(searchTerm));
                //var indexViewModel = new List<IndexViewModel>();
                //foreach (var n in auditorList)
                //{
                //    var mygroup = _repository.Find<Group>(n.GroupId);

                //    var model = new IndexViewModel
                //    {
                //        Firstname = n.FirstName,
                //        UserName = n.UserName,
                //        Lastname = n.LastName,
                //        Id = n.Id,
                //        GroupName = mygroup.Name,
                //        Maker = n.Maker,
                //        Email = n.Email,
                //        Country = n.Country,
                //        PhoneNumber = n.PhoneNumber,
                //        Cheker = n.Cheker,
                //        Enabled = n.Enabled,
                //        StatusOptions = n.Status
                //    };
                //    indexViewModel.Add(model);
                //}
                //_getVals.LogAudit(User.Identity.GetUserName(), "Viewed", Request.UserHostName, "Viewed Users Listing ",
                //    "ISA", "UserManagement");
                //return View(indexViewModel.ToPagedList(pageNumber, PageSize)); //.ToPagedList(pageNumber, PageSize)
            
        }