Exemplo n.º 1
0
        public JsonResult GetCities()
        {
            var config = _autoMapperConfigaration.Create <City, CityVM>();
            var cities = config.Map <IEnumerable <CityVM> >(_city.GetAllCities());

            return(Json(cities, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> GetCities()
        {
            try
            {
                var data = await cityService.GetAllCities();

                return(StatusCode(StatusCodes.Status200OK, data));
            }
            catch (Exception ex)
            {
                // Log exception code goes here
                return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message));
            }
        }
Exemplo n.º 3
0
        public async Task <ActionResult <IEnumerable <CityView> > > Get()
        {
            var result = await _service.GetAllCities();

            return(Ok(_mapper.Map <IEnumerable <CityView> >(result)));
        }