Exemplo n.º 1
0
        public ActionResult Create([Bind(Include = "ID,Disciplina,ID_Curso")] tbl_Disciplina tbl_Disciplina)
        {
            if (ModelState.IsValid)
            {
                db.tbl_Disciplina.Add(tbl_Disciplina);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ID_Curso = new SelectList(db.tbl_Curso, "ID", "Curso", tbl_Disciplina.ID_Curso);
            return(View(tbl_Disciplina));
        }
Exemplo n.º 2
0
        public ActionResult Create([Bind(Include = "ID,Nome,Matricula,ID_Curso")] tbl_Aluno tbl_Aluno)
        {
            if (ModelState.IsValid)
            {
                db.tbl_Aluno.Add(tbl_Aluno);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ID_Curso = new SelectList(db.tbl_Disciplina, "ID", "Disciplina", tbl_Aluno.ID_Curso);
            return(View(tbl_Aluno));
        }
Exemplo n.º 3
0
        public JsonResult Deletar(int id)
        {
            try
            {
                tbl_Curso curso = db.tbl_Curso.Find(id);

                if (curso != null)
                {
                    db.tbl_Curso.Remove(curso);
                    db.SaveChanges();
                    return(Json(true, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(false, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }