예제 #1
0
 public virtual List <Categoria> getCategoria(int Id = -1)
 {
     try
     {
         if (Id == -1)
         {
             return(_CategoriaRepositorio.GetTodos().ToList());
         }
         else
         {
             return(_CategoriaRepositorio.Get(p => p.Id == Id).ToList());
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #2
0
        public Categorias GetCategoria(int id)
        {
            Categorias item = categoria.Get(id);

            if (item == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
            return(item);
        }
예제 #3
0
        public async Task <Categoria> GetCategoria(int codigoCategoria)
        {
            try
            {
                _logger.LogInformation($"Busca de categoria por codigo. Codigo: {codigoCategoria}");

                var categoria = await _categoriaRepositorio.Get(codigoCategoria);

                if (categoria == null)
                {
                    throw new Exception("Not found");
                }

                return(categoria);
            }
            catch (Exception ex)
            {
                _logger.LogError($"Erro ao salvar categoria. Detalhes: {ex.Message}");
                throw;
            }
        }