Ejemplo n.º 1
0
        public TimeModelConsulta Editar(int id)
        {
            try
            {
                TimeDal d = new TimeDal();
                Time    t = d.FindById(id);

                if (t != null)
                {
                    var model = new TimeModelConsulta();
                    model.IdTime       = t.IdTime;
                    model.Nome         = t.Nome;
                    model.DataFundacao = t.DataFundacao.ToString("dd/MM/yyyy");

                    return(model);
                }
                else
                {
                    throw new Exception("Time não encontrado.");
                }
            }
            catch (Exception e)
            {
                throw new Exception("Erro: " + e.Message);
            }
        }
Ejemplo n.º 2
0
        public JsonResult Editar(TimeModelEdicao model)
        {
            try
            {
                TimeDal d = new TimeDal();
                Time t = d.FindById(model.IdTime);

                if (t != null)
                {
                    model.Nome = t.Nome;
                    model.DataFundacao = t.DataFundacao;
                }

                return Json(model);
            }
            catch (Exception e)
            {
                return Json(e.Message);
            }
        }
Ejemplo n.º 3
0
        public string Excluir(int id)
        {
            try
            {
                TimeDal d = new TimeDal();
                Time    t = d.FindById(id);

                if (t != null)
                {
                    d.Delete(t);
                    return("Time excluído.");
                }
                else
                {
                    return("Time não encontrado.");
                }
            }
            catch (Exception e)
            {
                return(e.Message);
            }
        }
Ejemplo n.º 4
0
        public ActionResult Editar(int id)
        {
            var model = new TimeModelEdicao();

            try
            {
                TimeDal d = new TimeDal();
                Time t = d.FindById(id);

                if (t != null)
                {
                    model.IdTime = t.IdTime;
                    model.Nome = t.Nome;
                    model.DataFundacao = t.DataFundacao;
                }
            }
            catch (Exception e)
            {
                ViewBag.Mensagem = e.Message;
            }
            return View(model);
        }
Ejemplo n.º 5
0
        public JsonResult Excluir(TimeModelEdicao model)
        {
            try
            {
                TimeDal d = new TimeDal();
                Time t = d.FindById(model.IdTime);

                if (t != null)
                {
                    d.Delete(t);

                    return Json("Time excluído, atualizando...");
                }
                else
                {
                    return Json("Time não encontrado.");
                }
            }
            catch (Exception e)
            {
                return Json(e.Message);
            }
        }
Ejemplo n.º 6
0
        public ActionResult Excluir(int id)
        {
            try
            {
                TimeDal d = new TimeDal();
                d.Delete(d.FindById(id));

                ViewBag.Mensagem = "Time excluído com sucesso.";
            }
            catch (Exception e)
            {
                ViewBag.Mensagem = e.Message;
            }

            return RedirectToAction("Consulta");
        }