Exemplo n.º 1
0
        public ActionResult <IEnumerable <LocationDTO> > GetCountries()
        {
            LocationMapper      locationMapper      = MapperFactory.createLocationMapper();
            GetCountriesCommand commandGetCountries = CommandFactory.GetCountriesCommand();

            commandGetCountries.Execute();
            var result = commandGetCountries.GetResult();

            _logger?.LogInformation($"Obtenido los paises exitosamente");
            return(locationMapper.CreateDTOList(result));
        }
Exemplo n.º 2
0
        public void CreateDTOListTest()
        {
            LocationMapper  _locationMapper = MapperFactory.createLocationMapper();
            Location        entity          = EntityFactory.CreateLocation(1, "Venezolania", "cagua");
            List <Location> entities        = new List <Location>();

            entities.Add(entity);
            entities.Add(entity);
            var result = _locationMapper.CreateDTOList(entities);

            Assert.IsInstanceOf <List <LocationDTO> >(result);
        }
Exemplo n.º 3
0
        public ActionResult <IEnumerable <LocationDTO> > GetCitiesByCountry([FromRoute] int countryId)
        {
            try
            {
                GetLocationByIdCommand commandId = CommandFactory.GetLocationByIdCommand(countryId);
                commandId.Execute();

                LocationMapper            locationMapper    = MapperFactory.createLocationMapper();
                GetCitiesByCountryCommand commandIByCountry = CommandFactory.GetCitiesByCountryCommand(countryId);
                commandIByCountry.Execute();
                var result = commandIByCountry.GetResult();
                _logger?.LogInformation($"Obtenida las ciudades por pais id {countryId} exitosamente");
                return(locationMapper.CreateDTOList(result));
            }
            catch (LocationNotFoundException ex)
            {
                _logger?.LogWarning($"Location con id {countryId} no encontrada");
                return(NotFound($"Location with id {countryId} not found"));
            }
        }