public async Task <IActionResult> Edit(int id, Emocao emocao) { _usuarioLogado = GetUser().Result; if (id != emocao.ID) { return(NotFound()); } if (ModelState.IsValid) { try { //emocao.UsuarioInclusao = EmocaoAnterior.UsuarioInclusao; //emocao.DataInclusao = EmocaoAnterior.DataInclusao; emocao.UsuarioAlteracao = _usuarioLogado.Id; emocao.DataAlteracao = _dataAtual; emocao.Ativo = true; _context.Update(emocao); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmocaoExists(emocao.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(emocao)); }
public async Task <IActionResult> Create([Bind("Descricao")] Emocao emocao) { _usuarioLogado = GetUser().Result; if (ModelState.IsValid) { emocao.UsuarioInclusao = _usuarioLogado.Id; emocao.UsuarioAlteracao = _usuarioLogado.Id; emocao.DataInclusao = _dataAtual; emocao.DataAlteracao = _dataAtual; emocao.Ativo = true; _context.Add(emocao); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(emocao)); }