public IActionResult Post([FromBody] PaginationClienteModel pagination)
        {
            try
            {
                if (!pagination.IsValid())
                {
                    return(BadRequest("Informe corretamente os campos de pesquisa."));
                }

                IEnumerable <ClienteModel> listClienteModel = ClienteModel.ToListModel(_clienteBusiness.Pagination(pagination.Search(),
                                                                                                                   pagination.Skip,
                                                                                                                   pagination.Take));

                if (listClienteModel == null)
                {
                    return(NotFound());
                }

                return(Ok(ListBodyModel <ClienteModel> .ToBodyList(listClienteModel)));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.Message));
            }
        }
示例#2
0
        public IActionResult Post([FromBody] PaginationUnselectedFilmeModel paginationModel)
        {
            try
            {
                if (!paginationModel.IsValid())
                {
                    return(BadRequest("Informe corretamente os campos de pesquisa."));
                }

                IEnumerable <FilmeModel> listFilmeModel = FilmeModel.ToListModel(_filmeBusiness.PaginationUnselectedFilmes(paginationModel.Search(),
                                                                                                                           paginationModel.Skip,
                                                                                                                           paginationModel.Take,
                                                                                                                           FilmeModel.ToListDomain(paginationModel.filmesSelecionados)));

                if (listFilmeModel == null)
                {
                    return(NotFound());
                }

                return(Ok(ListBodyModel <FilmeModel> .ToBodyList(listFilmeModel)));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.Message));
            }
        }
        public IActionResult GetClientesInadimplentes()
        {
            try
            {
                IEnumerable <AluguelModel> currentModel = AluguelModel.ToListModel(_aluguelBusiness.Get(p => DateTime.Now > p.Devolucao));

                if (currentModel == null)
                {
                    return(NotFound());
                }

                return(Ok(ListBodyModel <AluguelModel> .ToBodyList(currentModel)));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.Message));
            }
        }
        public IActionResult GetAlugueisAtivos()
        {
            try
            {
                IEnumerable <AluguelModel> currentModel = AluguelModel.ToListModel(_aluguelBusiness.Get(p => p.Devolveu == null));

                if (currentModel == null)
                {
                    return(NotFound());
                }

                return(Ok(ListBodyModel <AluguelModel> .ToBodyList(currentModel)));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.Message));
            }
        }
示例#5
0
        public IActionResult GetByCliente(int clienteId)
        {
            try
            {
                IEnumerable <AluguelModel> currentModel = AluguelModel.ToListModel(_aluguelBusiness.Get(
                                                                                       p => p.ClienteId == clienteId && (p.Devolveu == null || p.Devolveu == DateTime.MinValue)));

                if (currentModel == null)
                {
                    return(NotFound());
                }

                return(Ok(ListBodyModel <AluguelModel> .ToBodyList(currentModel)));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.Message));
            }
        }