public PotentialClientsModel GetViewModel(PotentialClientsModel model)
        {
            var result = _potentialClientRepository.GetIncludeFull();


            if (model.selectedStatuses != null)
            {
                if (model.selectedManagers != null && model.selectedManagers.Any())
                {
                    result = result.Where(x => model.selectedManagers.Contains(x.UserId ?? -1));
                }

                if (model.selectedStatuses.Any())
                {
                    result = result.Where(x => model.selectedStatuses.Contains(x.StatusId));
                }

                if (!string.IsNullOrEmpty(model.q))
                {
                    result = result.Where(x => x.Name.ToLower().Contains(model.q.ToLower()));
                }
            }
            else
            {//defaul filters
                model.selectedStatuses = _statusRepository.Get(RootTypes.PotentialCLient)
                                         .Where(x => !x.IsHide)
                                         .Select(x => x.Id)
                                         .ToList();

                result = result.Where(x => model.selectedStatuses.Contains(x.StatusId));

                // model.pageViewModel = new PageViewModel(result.Count(), 1, PotentialClientsModel.ItemsPerPage);
            }

            model.Pclients = result
                             //.Skip((model.pageViewModel.PageNumber-1)*PotentialClientsModel.ItemsPerPage)
                             //.Take(PotentialClientsModel.ItemsPerPage)
                             .ToList()
                             .Select(x => Map(x))
                             .OrderByDescending(x => x.Created)
                             .ToList();


            model.PStatuses = _statusRepository.Get(RootTypes.PotentialCLient);
            model.userList  = _userRepository.GetFullUsers().Where(x => x.IsManager)
                              .ToList();

            return(model);
        }
Exemple #2
0
 public IActionResult Index(PotentialClientsModel model)
 {
     model = _potentialClientService.GetViewModel(model);
     return(View(model));
 }