public ActionResult Excluir(int tarefaId) { if (ModelState.IsValid) { var tarefa = _tarefaRepository.GetById(tarefaId); _tarefaRepository.Delete(tarefa); ViewBag.Mensagem = "Tarefa excluída com sucesso."; return(RedirectToAction("Index")); } return(View()); }
static void Main(string[] args) { var repo = new TarefaRepository(); DateTime today = DateTime.Today; var newTarefa = new Tarefas() { AreaJogo = "teste", Concluida = true, Funcionario = "Joao das Couves", Maquina = "ceifadeira", Operacao = "Corte", Data = new DateTime(today.Year, today.Month, today.Day, 10, 39, 30) }; repo.Add(newTarefa); var tarefas = repo.GetTarefasByFuncionarioAndDataAndConcluida("Joao das Couves", today, today, true); var tarefases = tarefas.ToList(); var edit = new Tarefas() { AreaJogo = "green", Concluida = true, Funcionario = "Joao das Couves2", Maquina = "rebarbadeira", Operacao = "tesourada", Data = new DateTime(today.Year, today.Month, today.Day, 10, 39, 30) }; repo.Edit(6, edit); repo.Delete(6); var todastarefas = repo.GetTarefas(); var todastarefas2 = todastarefas.ToList(); var tempotarefas = repo.GetTarefasByFuncionarioAndDataAndConcluida("Joao das Couves", today, today, true); var tempotarefases2 = tempotarefas.ToList(); Console.Read(); }
public IActionResult Exclusao(int id, [FromServices] UsuarioRepository usuarioRepository, [FromServices] TarefaRepository tarefaRepository) { var usuario = usuarioRepository.GetByEmail(User.Identity.Name); try { var tarefa = tarefaRepository.GetById(id); if (tarefa.IdUsuario == usuario.IdUsuario) { tarefaRepository.Delete(tarefa); TempData["MensagemSucesso"] = "Tarefa excluído com sucesso."; } } catch (Exception e) { TempData["MensagemErro"] = e.Message; } return(RedirectToAction("Consulta")); }
public IActionResult Delete(int id) { _repository.Delete(id); return(RedirectToAction("Index")); }
public ActionResult Apagar(int id) { repository.Delete(id); return(RedirectToAction("Index")); }