public async Task <IActionResult> Create(IngredietesViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var entity = _mapper.Map <Ingredientes>(vm);
                await _Repository.Add(entity);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(vm));
        }
        public async Task <IActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            var ingrediente = await _Repository.GetById(id.Value);

            if (ingrediente == null)
            {
                return(NotFound());
            }
            var vm = new IngredietesViewModel
            {
                Id = ingrediente.Id,
                NombreIngrediente = ingrediente.NombreIngrediente
            };

            return(View(vm));
        }
        public async Task <IActionResult> Edit(int id, IngredietesViewModel vm)
        {
            if (id != vm.Id)
            {
                return(NotFound());
            }
            if (ModelState.IsValid)
            {
                try
                {
                    var entity = new Ingredientes
                    {
                        Id = vm.Id,
                        NombreIngrediente = vm.NombreIngrediente
                    };
                    await _Repository.Update(entity);
                }
                catch (DbUpdateConcurrencyException)
                {
                    var isExists = await IngredientesExixst(vm.Id);

                    if (!isExists)
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }

                return(RedirectToAction(nameof(Index)));
            }

            return(View(vm));
        }