Exemple #1
0
        public IActionResult GetByNome(string nome)
        {
            ResponseDto <List <Restaurante> > response = new ResponseDto <List <Restaurante> >();

            try
            {
                RestauranteBll     bll          = new RestauranteBll(_context);
                List <Restaurante> restaurantes = bll.GetByNome(nome);

                response.Result = restaurantes;
                response.Status = StatusResponse.SUCCESS.Value;
            }
            catch (EntityNotFoundException ex)
            {
                response.Status  = StatusResponse.ERROR.Value;
                response.Message = ex.Message;
            }
            catch (Exception ex)
            {
                response.Status  = StatusResponse.ERROR.Value;
                response.Message = "Erro ao consultar restaurante: " + ex.Message;
            }

            return(new ObjectResult(response));
        }