예제 #1
0
 public ActionResult AdicionaJogo(Jogo Jogo)
 {
     try {
         Jogo.ativo = true;
         contexto.Jogo.Add(Jogo);
         contexto.SaveChanges();
         TempData["sucess"] = "Jogo salvo com sucesso";
     }
     catch (Exception e)
     {
         TempData["error"] = "Erro ao salvar o Jogo";
     }
     return(RedirectToAction("ListaJogos"));
 }
예제 #2
0
 public ActionResult AdicionaEmprestimo(emprestimo_jogo Emprestimo)
 {
     try {
         Emprestimo.data   = DateTime.Now;
         Emprestimo.status = "e";
         contexto.emprestimo_jogo.Add(Emprestimo);
         contexto.SaveChanges();
         TempData["sucess"] = "Emprestimo salvo com sucesso";
     }
     catch (Exception e)
     {
         TempData["error"] = "Erro ao salvar o Emprestimo";
     }
     return(RedirectToAction("ListaEmprestimos"));
 }
예제 #3
0
 public ActionResult AdicionaAmigo(Amigo Amigo)
 {
     try {
         var amigoExistente = (from c in contexto.Amigo where c.cpf == Amigo.cpf select c).FirstOrDefault();
         if (amigoExistente == null)
         {
             Amigo.ativo = true;
             contexto.Amigo.Add(Amigo);
             contexto.SaveChanges();
             TempData["sucess"] = "Amigo salvo com sucesso";
         }
         else
         {
             TempData["error"] = "Já existe um amigo com este cpf";
             return(View(Amigo));
         }
     }
     catch (Exception e)
     {
         TempData["error"] = "Erro ao salvar o amigo";
     }
     return(RedirectToAction("ListaAmigos"));
 }