// GET: Contato/Excluir public ActionResult Excluir() { TarefaExclusaoModel model = new TarefaExclusaoModel(); try { int idTarefa = int.Parse(Request.QueryString["id"]); TarefaRepositorio rep = new TarefaRepositorio(); Tarefa t = rep.FindById(idTarefa); model.IdTarefa = t.IdTarefa; model.Nome = t.Nome; model.Descricao = t.Descricao; model.DataEntrega = t.DataEntrega; } catch (Exception e) { ViewBag.Mensagem = e.Message; } return(View(model)); }
public ActionResult Excluir(TarefaExclusaoModel model) { if (ModelState.IsValid) { try { UsuarioRepositorio repUsuario = new UsuarioRepositorio(); Tarefa t = new Tarefa(); t.Usuario = repUsuario.FindByLogin(User.Identity.Name); t.IdTarefa = model.IdTarefa; t.Nome = model.Nome; t.Descricao = model.Descricao; t.DataEntrega = model.DataEntrega; TarefaRepositorio rep = new TarefaRepositorio(); //rep.Delete(t); //gravando.. ViewBag.Mensagem = "Tarefa excluída com sucesso."; ModelState.Clear(); //limpar os campos do formulário.. } catch (Exception e) { ViewBag.Mensagem = e.Message; } } return(View()); }
public ActionResult Excluir(TarefaExclusaoModel model) { if (ModelState.IsValid) { try { UsuarioRep repUsuario = new UsuarioRep(); Tarefa t = new Tarefa(); t.Usuario = repUsuario.FindByName(User.Identity.Name); t.IdTarefa = model.IdTarefa; t.Titulo = model.Titulo; t.Descricao = model.Descricao; TarefaRep rep = new TarefaRep(); rep.Delete(t); ModelState.Clear(); } catch (Exception e) { ViewBag.Mensagem = e.Message; } } return(View()); }