Esempio n. 1
0
        public ActionResult ObterTodos()
        {
            _repTime = new Rep.TimeRepositorio();

            ModelState.Clear();
            return(View(_repTime.ObterTimes()));
        }
Esempio n. 2
0
        public ActionResult ObterPorId(int id)
        {
            try
            {
                _repTime = new Rep.TimeRepositorio();


                return(View(_repTime.ObterPorId(id)));
            }
            catch (Exception e)
            {
                return(View(ObterTodos()));
            }
        }
Esempio n. 3
0
 public ActionResult ExlcuirTime(int id)
 {
     try
     {
         _repTime = new Rep.TimeRepositorio();
         if (_repTime.ExcluirTime(id))
         {
             ViewBag.Mensagem = "Time excluido";
         }
         return(RedirectToAction("ObterTodos"));
     }
     catch (Exception e)
     {
         return(View(ObterTodos()));
     }
 }
Esempio n. 4
0
        public ActionResult EditarTime(int id, Models.Time time)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    _repTime = new Rep.TimeRepositorio();
                    _repTime.AtualizarTime(time);

                    return(RedirectToAction("ObterTodos"));
                }
                catch (Exception)
                {
                    return(View());
                }
            }
            return(View());
        }
Esempio n. 5
0
        public ActionResult IncluirTime(Models.Time time)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _repTime = new Rep.TimeRepositorio();

                    if (_repTime.AdicionarTime(time))
                    {
                        ViewBag.Mensagem = "Time Cadastrado com sucesso!";
                    }
                    return(RedirectToAction("ObterTodos"));
                }
                return(View());
            }
            catch (Exception)
            {
                return(View("ObterTodos"));
            }
        }
Esempio n. 6
0
 public ActionResult EditarTime(int id)
 {
     _repTime = new Rep.TimeRepositorio();
     return(View(_repTime.ObterTimes().Find(t => t.id == id)));
 }