public async Task <IActionResult> Edit(string id, [Bind("Id,Question_statement,Time,CorrectAnswer,Options,Question_type")] Question question) { if (id != question.QuestionId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(question); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!QuestionExists(question.QuestionId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(question)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Title,ReleaseDate,Genre,Price")] Movie movie) { if (id != movie.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(movie); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MovieExists(movie.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(movie)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Departamento departamento) { if (id != departamento.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(departamento); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DepartamentoExists(departamento.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(departamento)); }
public void Update(Vendedor vendedor) { if (!_contexto.Vendedor.Any(x => x.Id == vendedor.Id)) { throw new NotFoundException("Id não encontrado!"); } try { _contexto.Update(vendedor); _contexto.SaveChanges(); } catch (DbUpdateConcurrencyException e) { throw new DbConcurrencyException(e.Message); } }