public async Task <IActionResult> Edit(int id, [Bind("TagId,Nome")] Tag tag) { if (id != tag.TagId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(tag); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TagExists(tag.TagId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(tag)); }
public async Task <IActionResult> Edit(int id, [Bind("PerguntaId,Titulo,Descricao,DataPublicacao,AutorId,CategoriaId")] Pergunta pergunta) { if (id != pergunta.PerguntaId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(pergunta); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PerguntaExists(pergunta.PerguntaId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["AutorId"] = new SelectList(_context.Autores, "AutorId", "Login", pergunta.AutorId); ViewData["CategoriaId"] = new SelectList(_context.Categorias, "CategoriaId", "Descricao", pergunta.CategoriaId); return(View(pergunta)); }
public T Update(T itemToUpdate) { var entity = dbContext.Update <T>(itemToUpdate); dbContext.SaveChanges(); return(entity.Entity); }
public async Task <IActionResult> Edit(int id, [Bind("CategoriaId,Titulo,Descricao")] Categoria categoria) { if (id != categoria.CategoriaId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(categoria); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CategoriaExists(categoria.CategoriaId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(categoria)); }
public User Update(User user) { _context.Update(user); return(GetById(user.UserId)); }