示例#1
0
        public async Task <IActionResult> Index()
        {
            try
            {
                DataResponse <IngredienteDTO> ingredientes = await _ingredienteService.GetData();

                var configuration = new MapperConfiguration(cfg =>
                {
                    cfg.CreateMap <IngredienteDTO, IngredienteQueryViewModel>();
                });
                IMapper mapper = configuration.CreateMapper();

                List <IngredienteQueryViewModel> dados = mapper.Map <List <IngredienteQueryViewModel> >(ingredientes.Data);

                return(View(dados));
            }
            catch (Exception)
            {
                return(View());
            }
        }