public ActionResult EditProfessorDisciplina(short idDisciplina, int idProfessorDisciplina) { if (Roles.IsUserInRole(User.Identity.Name, "Administrador")) { Professor_Disciplina pd = new Professor_Disciplina(); pd.idDisciplina = idDisciplina; int idProfessor = 1; int idTurma = 1; int idCurso = 1; if (idProfessorDisciplina != 0) { pd = professorDisciplinaModel.obterProfessorDisciplina(idProfessorDisciplina); idProfessor = pd.idProfessor; idTurma = pd.idTurma; idCurso = pd.Disciplina.idCurso; } ViewBag.idCurso = new SelectList(cursoModel.todosCursos(), "idCurso", "Descricao", idCurso); ViewBag.idTurma = new SelectList(turmaModel.obterTurmasPorCurso(idCurso), "idTurma", "Identificacao", idTurma); ViewBag.idProfessor = new SelectList(professorModel.todosProfessores(), "idProfessor", "Pessoa.Nome", idProfessor); return(View(pd)); } return(Redirect("/Shared/Restrito")); }
public ActionResult DeleteProfessorDisciplina(int idProfessorDisciplina) { if (Roles.IsUserInRole(User.Identity.Name, "Administrador")) { Professor_Disciplina pd = professorDisciplinaModel.obterProfessorDisciplina(idProfessorDisciplina); professorDisciplinaModel.excluirProfessorDisciplina(pd); return(RedirectToAction("ListaProfessorDisciplina", new { idDisciplina = pd.idDisciplina })); } return(Redirect("/Shared/Restrito")); }
public string excluirProfessorDisciplina(Professor_Disciplina pa) { string erro = null; try { db.DeleteObject(pa); db.SaveChanges(); } catch (Exception ex) { erro = ex.Message; } return(erro); }
public string adicionarProfessorDisciplina(Professor_Disciplina pd) { string erro = null; try { db.Professor_Disciplina.AddObject(pd); db.SaveChanges(); } catch (Exception ex) { erro = ex.Message; } return(erro); }
public async Task <Response> Delete(Professor_Disciplina models) { using (AppProfessorContext context = new AppProfessorContext()) { using (Transation_Scoper db = new Transation_Scoper(context)) { var result = await db.DoDelete(models).EndTransaction(); return(new Response { IsSucess = result.estado, list = models, Messgems = result.Exception, }); } } }
public string editarProfessorDisciplina(Professor_Disciplina pd) { string erro = null; try { if (pd.EntityState == System.Data.EntityState.Detached) { db.Professor_Disciplina.Attach(pd); } db.ObjectStateManager.ChangeObjectState(pd, System.Data.EntityState.Modified); db.SaveChanges(); } catch (Exception ex) { erro = ex.Message; } return(erro); }
public ActionResult EditProfessorDisciplina(Professor_Disciplina pd, Professor p, Curso c, Turma t) { if (Roles.IsUserInRole(User.Identity.Name, "Administrador")) { ViewBag.idCurso = new SelectList(cursoModel.todosCursos(), "idCurso", "Descricao", c); ViewBag.idTurma = new SelectList(turmaModel.obterTurmasPorCurso(c.idCurso), "idTurma", "Identificacao", t); ViewBag.idProfessor = new SelectList(professorModel.todosProfessores(), "idProfessor", "Pessoa.Nome", p); string erro = null; if (pd.idProfessorDisciplina == 0) { erro = professorDisciplinaModel.adicionarProfessorDisciplina(pd); } else { erro = professorDisciplinaModel.editarProfessorDisciplina(pd); } if (erro == null) { return(RedirectToAction("ListaProfessorDisciplina", new { idDisciplina = pd.idDisciplina })); } else { ViewBag.Erro = erro; return(View(pd)); } } return(Redirect("/Shared/Restrito")); }