Ejemplo n.º 1
0
        public async Task <IActionResult> Index(
            [Bind("LastName")] UserInformationAdminSearchDto searchDto = null,
            [Bind("SortOrder,CurrentSort,CurrentFilter,SearchString,IncludedProperties,Page,PageNumber,PageSize")] PageListActionDto pageListActionDto = null,
            Guid?id = null)
        {
            var viewModel = await
                            _service.GetIndexViewAsync(searchDto, pageListActionDto, id);

            return(View(viewModel));
        }
Ejemplo n.º 2
0
        public async Task <UserInfoAdminIndexViewModel> GetIndexViewAsync(UserInformationAdminSearchDto searchDto,
                                                                          PageListActionDto pageListActionDto, Guid?id)
        {
            var indexViewModel = new UserInfoAdminIndexViewModel();

            if (pageListActionDto == null)
            {
                pageListActionDto = new PageListActionDto();
            }
            if (searchDto == null)
            {
                searchDto = new UserInformationAdminSearchDto();
            }

            indexViewModel.SearchDto = searchDto;

            //This section used to set ascending or descending order
            indexViewModel.SortDto.FirstName =
                String.IsNullOrEmpty(pageListActionDto.SortOrder) ? "FirstName_desc" : "";

            indexViewModel.SortDto.LastName =
                pageListActionDto.SortOrder == "LastName" ? "LastName_desc" : "LastName";

            indexViewModel.SortDto.UserName =
                pageListActionDto.SortOrder == "UserName" ? "UserName_desc" : "UserName";

            indexViewModel.Title       = "Manage " + _TitleDesc + "s";
            pageListActionDto.PageSize = 10;

            indexViewModel.PageListAction.CurrentSort = pageListActionDto.SortOrder;

            //var userInformations = await _unitOfWork.ApplicationUserRepository.GetAsync(ExpressionBuilder<ApplicationUser>.GetExpression(searchDto),
            //    GetSortOrder(pageListActionDto.SortOrder), "");

            var userInformations = await _unitOfWork.ApplicationUserRepository.GetAsync(await UserSearch(searchDto),
                                                                                        GetSortOrder(pageListActionDto.SortOrder), "");

            indexViewModel.UserInformations = await userInformations
                                              .ToPagedListAsync((pageListActionDto.Page ?? 1), pageListActionDto.PageSize);

            //Add items for selected user
            if (id != null)
            {
                var selectedUserInformation = await _unitOfWork.ApplicationUserRepository.SingleOrDefaultAsync(
                    u => u.Id == id, "ApplicationUserUserRoles,ApplicationUserUserRoles.ApplicationUserRole");

                indexViewModel.SelectedUserInformation = selectedUserInformation;
            }

            return(indexViewModel);
        }
Ejemplo n.º 3
0
        private async Task <Expression <Func <ApplicationUser, bool> > > UserSearch(UserInformationAdminSearchDto searchDto)
        {
            var predicate = PredicateBuilder.New <ApplicationUser>(true);

            //if (searchDto.IsCreditIssued == true)
            //    predicate = predicate.Or(p => p.ClaimStatusId == (int)ClaimStatus.CreditIssued);
            //if (searchDto.IsApproved == true)
            //    predicate = predicate.Or(p => p.ClaimStatusId == (int)ClaimStatus.Approved);
            //if (searchDto.IsDenied == true)
            //    predicate = predicate.Or(p => p.ClaimStatusId == (int)ClaimStatus.Denied);
            //if (searchDto.IsCurrent == true || (!searchDto.IsApproved == true && !searchDto.IsDenied == true))
            //    predicate = predicate.Or(p => p.ClaimStatusId > (int)ClaimStatus.Approved);

            //if (!string.IsNullOrEmpty(searchDto.MtuSalesOrderNumber))
            //    predicate = predicate.And(s => EF.Functions.Like(s.MtuSalesOrderNumber.ToString(), searchDto.MtuSalesOrderNumber.Replace("*", "%")));

            //if (!string.IsNullOrEmpty(searchDto.DistributorInfoId))
            //    predicate = predicate.And(s => EF.Functions.Like(s.DistributorInfoId.ToString(), searchDto.DistributorInfoId.Replace("*", "%")));

            //if (!await _userResolverService.IsUserInRoleAsync("Administrator,Approver"))
            //{
            //    var user = await _userResolverService.GetCurrentUserAsync();
            //    predicate = predicate.And(p =>
            //        user.UserDistributors.Select(d => d.DistributorInfo).Select(c => c.DistributorInfoId).ToList()
            //            .Contains(p.DistributorInfoId));
            //}


            if (!string.IsNullOrEmpty(searchDto.LastName))
            {
                predicate = predicate.And(s => EF.Functions.Like(s.LastName, searchDto.LastName.Replace("*", "%")));
            }

            if (!await _userResolverService.IsUserInRoleAsync("Administrator,Approver"))
            {
            }

            return(predicate);
        }
 public UserInfoAdminIndexViewModel()
 {
     SearchDto      = new UserInformationAdminSearchDto();
     SortDto        = new UserInformationAdminSortDto();
     PageListAction = new PageListActionDto();
 }