public static void ExcluirProjeto(CadProjeto projeto) { using (var ctx = new ProjectManagerConnection()) { ctx.Entry <CadProjeto>(projeto).State = EntityState.Deleted; ctx.SaveChanges(); } }
public static void AlterarProjeto(CadProjeto projeto) { using (var ctx = new ProjectManagerConnection()) { ctx.Entry <CadProjeto>(projeto).State = EntityState.Modified; ctx.SaveChanges(); } }
public static void CadastrarProjeto(CadProjeto projeto) { using (var ctx = new ProjectManagerConnection()) { ctx.CadProjeto.Add(projeto); ctx.SaveChanges(); } }
public static void IncluirProjeto(CadProjeto projeto) { using (var ctx = new ProjetoConnection()) { ctx.CadProjetos.Add(projeto); ctx.SaveChanges(); } }
public ActionResult ExcluirProjeto(CadProjeto projeto) { try { ProjetosDao.ExcluirProjeto(projeto); return(RedirectToAction("ListarProjetos")); } catch (Exception ex) { ViewBag.MensagemErro = ex.Message; return(View("_Erro")); } }
public ActionResult IncluirProjeto(CadProjeto projeto) { try { if (!ModelState.IsValid) { return(IncluirProjeto()); } ProjetosDao.IncluirProjeto(projeto); TempData["Mensagem"] = "Projeto cadastrado com sucesso..."; return(RedirectToAction("Index")); } catch (Exception ex) { ViewBag.MensagemErro = ex.Message; return(View("_erro")); } }
public ActionResult AlterarProjeto(CadProjeto projeto) { try { if (!ModelState.IsValid) { throw new Exception("ModelState is invalid!"); } ProjetosDao.AlterarProjeto(projeto); TempData["Mensagem"] = "Projeto alterado com sucesso..."; return(RedirectToAction("Index")); } catch (Exception ex) { ViewBag.MensagemErro = ex.Message; return(View("_erro")); } }
public ActionResult AlterarProjeto(CadProjeto projeto) { try { if (!ModelState.IsValid) { return(View()); } ProjetosDao.AlterarProjeto(projeto); return(RedirectToAction("ListarProjetos")); } catch (Exception ex) { ViewBag.MensagemErro = ex.Message; return(View("_Erro")); } }