public async Task <IActionResult> Edit(int id, [Bind("Id,Description")] Specie specie)
        {
            if (id != specie.Id)
            {
                return(new NotFoundViewResult("SpecieNotFound"));
            }

            if (ModelState.IsValid)
            {
                try
                {
                    await _specieRepository.UpdateAsync(specie);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!await _specieRepository.ExistAsync(specie.Id))
                    {
                        return(new NotFoundViewResult("SpecieNotFound"));
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(specie));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Edit(EditViewModel model)
        {
            if (ModelState.IsValid)
            {
                var specie = _converterHelper.ToSpecieEntity(model);
                await _specieRepository.UpdateAsync(specie);

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

            return(View(model));
        }