Esempio n. 1
0
        public async Task <IEnumerable <ClienteDTO> > List(UsuarioDTO userLogged, ClienteFilterDTO filter = null)
        {
            IEnumerable <Cliente> entities;

            entities = await _clienteRepository.ListBy(cliente =>
                                                       (
                                                           (cliente.IdEmpresa == userLogged.IdEmpresa) &&
                                                           (!filter.CreationDateFrom.HasValue || cliente.CreationDate >= filter.CreationDateFrom.Value) &&
                                                           (!filter.CreationDateTo.HasValue || cliente.CreationDate <= filter.CreationDateTo.Value) &&

                                                           (
                                                               filter.Name.IsNullOrEmpty() ||
                                                               cliente.Cuil.ToLower().Contains(filter.Name) ||
                                                               cliente.RazonSocial.ToLower().Contains(filter.Name) ||
                                                               cliente.Telefono.ToLower().Contains(filter.Name) ||
                                                               cliente.Email.ToLower().Contains(filter.Name))
                                                       ) &&
                                                       cliente.Active == true,
                                                       s => s.Empresa,
                                                       s => s.Servicio
                                                       );

            var dtos = _mapper.Map <IEnumerable <ClienteDTO> >(entities);

            return(dtos);
        }
Esempio n. 2
0
        public async Task <IActionResult> List(string name = null, DateTime?creationDateFrom = null, DateTime?creationDateTo = null, int?idEmpresa = null)
        {
            try
            {
                var filters  = new ClienteFilterDTO(name, creationDateFrom, creationDateTo, idEmpresa);
                var entities = await _clienteService.List(this.Usuario, filters);

                return(Ok(entities));
            }
            catch (Exception)
            {
                throw;
            }
        }