public async Task <IActionResult> Index(string mensagem)
        {
            _logger.Debug("Listagem de projetos");

            if (!string.IsNullOrEmpty(mensagem))
            {
                ViewBag.Mensagem = mensagem;
            }

            var lista = _mapper.Map <IEnumerable <ProspectViewModel> >(await _context.ObterTodos());

            var vm = new ProspectListViewModel
            {
                ProspectViewModels = lista,
                Customers          = _mapper.Map <IEnumerable <CustomerViewModel> >(await _customerRepository.ObterTodos()),
                Employees          = _mapper.Map <IEnumerable <EmployeeViewModel> >(await _employeeRepository.ObterTodos())
            };

            return(View(vm));
        }
        public async Task <IActionResult> SearchProspects(ProspectListViewModel prospectViewModel)
        {
            _logger.Debug("Listagem de projetos filtrados");

            var lista = _mapper.Map <IEnumerable <ProspectViewModel> >(await _context.ObterTodos());

            if (!string.IsNullOrEmpty(prospectViewModel.CustomerIds))
            {
                var customers = new List <Guid>();
                foreach (var item in prospectViewModel.CustomerIds.Split(','))
                {
                    customers.Add(Guid.Parse(item));
                }
                lista = lista.Where(x => customers.Contains(x.CustomerId));
            }

            if (!string.IsNullOrEmpty(prospectViewModel.Types))
            {
                var types = new List <int>();
                foreach (var item in prospectViewModel.Types.Split(','))
                {
                    types.Add(Convert.ToInt32(item));
                }
                lista = lista.Where(x => types.Contains(x.Type));
            }

            if (!string.IsNullOrEmpty(prospectViewModel.Status))
            {
                var status = new List <string>();
                foreach (var item in prospectViewModel.Status.Split(','))
                {
                    status.Add(item);
                }
                lista = lista.Where(x => status.Contains(x.Status));
            }

            if (!string.IsNullOrEmpty(prospectViewModel.EmployeeIds))
            {
                var employees = new List <Guid>();
                foreach (var item in prospectViewModel.EmployeeIds.Split(','))
                {
                    employees.Add(Guid.Parse(item));
                }
                lista = lista.Where(x => employees.Contains(x.EmployeeId));
            }

            if (!string.IsNullOrEmpty(prospectViewModel.DateOpening))
            {
                var inicio = DateTime.Parse(prospectViewModel.DateOpening.Substring(0, 10));
                var fim    = DateTime.Parse(prospectViewModel.DateOpening.Substring(15, 10));
                lista = lista.Where(x => x.Opening >= inicio && x.Opening <= fim);
            }

            if (!string.IsNullOrEmpty(prospectViewModel.Temperatures))
            {
                var temperatures = new List <string>();
                foreach (var item in prospectViewModel.Temperatures.Split(','))
                {
                    temperatures.Add(item);
                }
                lista = lista.Where(x => temperatures.Contains(x.Temperature.ToString()));
            }

            var vm = new ProspectListViewModel
            {
                ProspectViewModels = lista
            };

            return(Json(new { isValid = true, html = Helper.RenderRazorViewToString(this, "_Lista", vm.ProspectViewModels) }));
        }