Exemplo n.º 1
0
 public ActionResult RemoveClasse(String id)
 {
     try
     {
         ClasseLiga cl = db.ClasseLiga.Find(Int32.Parse(id));
         db.ClasseLiga.Remove(cl);
         db.SaveChanges();
         return(Json(new { erro = "", retorno = 1 }, "text/plain", JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(new { erro = ex.Message, retorno = 0 }, "text/plain", JsonRequestBehavior.AllowGet));
     }
 }
Exemplo n.º 2
0
        public ActionResult AddClasse(String idLiga, String nome, String idCategoria)
        {
            try {
                int idCat = Int32.Parse(idCategoria);
                if (nome == "" || idCategoria == "" || idCat == 0)
                {
                    throw new Exception("Por favor preencha os campos obrigatórios(nome e categoria).");
                }
                ClasseLiga cl = new ClasseLiga();
                cl.LigaId      = Int32.Parse(idLiga);
                cl.Nome        = nome;
                cl.CategoriaId = idCat;
                db.ClasseLiga.Add(cl);
                db.SaveChanges();

                Categoria cat = db.Categoria.Find(idCat);
                return(Json(new { erro = "", retorno = 1, nome = cl.Nome, categoria = cat.Nome, IdClasseLiga = cl.Id }, "text/plain", JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { erro = ex.Message, retorno = 0 }, "text/plain", JsonRequestBehavior.AllowGet));
            }
        }