예제 #1
0
 public static void ExcluirProjeto(CadProjeto projeto)
 {
     using (var ctx = new ProjectManagerConnection())
     {
         ctx.Entry <CadProjeto>(projeto).State = EntityState.Deleted;
         ctx.SaveChanges();
     }
 }
예제 #2
0
 public static void AlterarProjeto(CadProjeto projeto)
 {
     using (var ctx = new ProjectManagerConnection())
     {
         ctx.Entry <CadProjeto>(projeto).State = EntityState.Modified;
         ctx.SaveChanges();
     }
 }
예제 #3
0
 public static void CadastrarProjeto(CadProjeto projeto)
 {
     using (var ctx = new ProjectManagerConnection())
     {
         ctx.CadProjeto.Add(projeto);
         ctx.SaveChanges();
     }
 }
예제 #4
0
 public static void IncluirProjeto(CadProjeto projeto)
 {
     using (var ctx = new ProjetoConnection())
     {
         ctx.CadProjetos.Add(projeto);
         ctx.SaveChanges();
     }
 }
예제 #5
0
 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"));
     }
 }
예제 #8
0
        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"));
            }
        }