コード例 #1
0
        public void GetCitiesByCountryCommandTest()
        {
            GetCitiesByCountryCommand commandIByCountry = CommandFactory.GetCitiesByCountryCommand(77);

            commandIByCountry.Execute();
            Assert.NotNull(commandIByCountry.GetResult());
        }
コード例 #2
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"));
            }
        }