예제 #1
0
 public ActionResult Deletar(int id)
 {
     try
     {
         var comandasRepository = new ComandasRepository();
         var comanda            = comandasRepository.Carregar(id);
         return(View(comanda));
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #2
0
        public ActionResult Index()
        {
            try
            {
                var listaDeComandas     = new ComandasRepository();
                var listaDeComandasDoBd = listaDeComandas.Listar();

                return(View(listaDeComandasDoBd));
            }
            catch (Exception ex)
            {
                throw;
            }
        }
예제 #3
0
        public ActionResult Deletar(Comanda comanda, FormCollection collection)
        {
            try
            {
                var comandaRepository = new ComandasRepository();

                if (comandaRepository.Excluir(comanda))
                {
                    ViewData["mensagem"] = "<h1>Usuario cadastrado com sucesso!</h1>";
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ViewData["mensagem"] = "<h1>DEU RUIM</h1>";
                    return(View(comanda));
                }
            }
            catch
            {
                return(View());
            }
        }
예제 #4
0
        public ActionResult Editar(Comanda comanda)
        {
            try
            {
                var comandaRepository = new ComandasRepository();

                if (comandaRepository.Salvar(comanda))
                {
                    ViewData["mensagem"] = "<h1>Usuario cadastrado com sucesso!</h1>";
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ViewData["mensagem"] = "<h1>DEU RUIM</h1>";
                    return(View(comanda));
                }
            }
            catch (Exception e)
            {
                throw;
            }
        }
예제 #5
0
        public ActionResult Editar(int id)
        {
            try
            {
                var comandasRepository = new ComandasRepository();
                var comanda            = comandasRepository.Carregar(id);

                if (!comanda.StatusComanda)
                {
                    return(View(comanda));
                }

                else
                {
                    ViewData["mensagem"] = "<h1>A comanda esta fechada, consulte ela em '/Detalhes/'</h1>";
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #6
0
        public ActionResult Cadastro(Comanda comanda)
        {
            try
            {
                var comandaRepository = new ComandasRepository();
                var validate          = comandaRepository.ValidarComandaExistente(comanda);

                if (!validate && comandaRepository.Salvar(comanda))
                {
                    ViewData["mensagem"] = "<h1>Usuario cadastrado com sucesso!</h1>";
                    return(RedirectToAction("Index"));
                }

                else
                {
                    ViewData["mensagem"] = "<h1>DEU RUIM</h1>";
                    return(View("Index"));
                }
            }
            catch (Exception e)
            {
                throw;
            }
        }