Ejemplo n.º 1
0
        public PaymentPaginated GetPaymentsByCompanies(List <int> companiesIds, int page, int limit)
        {
            if (companiesIds.Count() < 1)
            {
                throw new BadRequestException("Algo deu errado com esta requisição, atualize a página!");
            }

            List <Payment> payments = new List <Payment>();

            try
            {
                payments = _repository.GetPaymentsByCompanies(companiesIds, page, limit);
            } catch (Exception e)
            {
                throw new Exception($"Algo deu errado {e}");
            }

            if (payments.Count() < 1)
            {
                throw new NotFoundException("Nenhum pagamento encontrado");
            }

            PaymentPaginated paymentPaginated = new PaymentPaginated();

            paymentPaginated.payments = payments;
            paymentPaginated.total    = _repository.CountPaymentsByCompanies(companiesIds);

            return(paymentPaginated);
        }