public List <BrandType> GetBrands() { GetBrandsCommand getBrandsCommand = new GetBrandsCommand(); getBrandsCommand.Execute(); return(getBrandsCommand.CommandResult); }
public ActionResult <IEnumerable <BrandDTO> > GetBrands() { _logger?.LogInformation($"Inicio del servicio: [GET] https://localhost:5001/api/brands "); List <Brand> brands = new List <Brand>(); try { BrandMapper brandMapper = MapperFactory.CreateBrandMapper(); GetBrandsCommand command = CommandFactory.CreateGetBrandsCommand(); _logger?.LogInformation($" Ejecución del comando "); command.Execute(); return(Ok(brandMapper.CreateDTOList(command.GetResult()))); } catch (WithoutExistenceOfBrandsException ex) { _logger?.LogWarning($"No existen marcas en la base de datos"); return(StatusCode(404, ex.Message)); } catch (InternalServerErrorException ex) { _logger?.LogError("Error: " + ex.Ex.Message); return(StatusCode(500, ex.Message)); } catch (Exception) { _logger?.LogError("Error inesperado"); return(StatusCode(400)); } }