public T Add(T itemToAdd) { var entity = dbContext.Add <T>(itemToAdd); dbContext.SaveChanges(); return(entity.Entity); }
public async Task<IActionResult> Create([Bind("UserId,EmailAdress,Password,DateOfBirth,FirstName,LastName,University,GithubRating,CodeforcesRating,PhoneNumber,Adress,PointsAccumulated")] User user) { if (ModelState.IsValid) { _context.Add(user); await _context.SaveChangesAsync(); return RedirectToAction(nameof(Index)); } return View(user); }
public async Task <IActionResult> Create([Bind("AutorId,Nome,Login,Senha")] Autor autor) { if (ModelState.IsValid) { _context.Add(autor); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(autor)); }
public async Task <IActionResult> Create([Bind("TagId,Nome")] Tag tag) { if (ModelState.IsValid) { _context.Add(tag); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(tag)); }
public async Task <IActionResult> Create([Bind("CategoriaId,Titulo,Descricao")] Categoria categoria) { if (ModelState.IsValid) { _context.Add(categoria); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(categoria)); }
public async Task <IActionResult> Create([Bind("PerguntaId,Titulo,Descricao,DataPublicacao,AutorId,CategoriaId")] Pergunta pergunta) { if (ModelState.IsValid) { _context.Add(pergunta); await _context.SaveChangesAsync(); 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)); }