Beispiel #1
0
        // GET: Plato/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            var plato = await _repository.GetById(id.Value);

            if (plato == null)
            {
                return(NotFound());
            }
            var vm = _mapper.Map <PlatoViewModel>(plato);
            var IngredientesEntity = await _repositoryIngredientes.GetAll();

            List <IngredietesViewModel> listingredietesViewModelsvm = new List <IngredietesViewModel>();

            IngredientesEntity.ForEach(item => {
                var vmIngredientes = _mapper.Map <IngredietesViewModel>(item);
                listingredietesViewModelsvm.Add(vmIngredientes);
            });


            ViewBag.Ingredientes = listingredietesViewModelsvm;


            return(View());
        }
Beispiel #2
0
        public async Task <ActionResult <List <Ingredientes> > > Get()
        {
            var list = await _repository.GetAll();

            if (list.Count == 0)
            {
                return(NotFound());
            }

            return(list);
        }
        //Get Ingredientes
        public async Task <IActionResult> Index()
        {
            var listEntity = await _Repository.GetAll();

            List <IngredietesViewModel> vms = new List <IngredietesViewModel>();

            listEntity.ForEach(item =>
            {
                var vm = _mapper.Map <IngredietesViewModel>(item);
                vms.Add(vm);
            });


            return(View(vms));
        }