/// <summary> /// Apresenta a tela para inclusão de uma nova turma /// </summary> /// <returns></returns> public ActionResult Create() { using (ctx) { // Cria uma lista de escolas para preencher o dropdownlist var srvCollege = new CollegeService(ctx); var lstColleges = srvCollege.GetAll(); ViewBag.Colleges = new SelectList(lstColleges, "ID", "Name"); } return PartialView("_ModalForm", new Classroom()); }
/// <summary> /// Lista todas as escolas cadastradas /// </summary> /// <returns></returns> public ActionResult Index() { using (ctx) { var srvCollege = new CollegeService(ctx); var lstColleges = srvCollege.GetAll(); return View(lstColleges); } }
/// <summary> /// Apresenta a tela para edição de uma turma /// </summary> /// <param name="id">Código de identificação da turma</param> /// <returns></returns> public ActionResult Edit(int id) { using (ctx) { var srvClassroom = new ClassroomService(ctx); var oClassroom = srvClassroom.Sigle(id); // Cria uma lista de escolas para preencher o dropdownlist var srvCollege = new CollegeService(ctx); var lstColleges = srvCollege.GetAll(); ViewBag.Colleges = new SelectList(lstColleges, "ID", "Name"); return PartialView("_ModalForm", oClassroom); } }
public ActionResult Save(Classroom oClassroom) { using (ctx) { if (ModelState.IsValid) { try { var srvClassroom = new ClassroomService(ctx); if (oClassroom.ID == 0) srvClassroom.InsertAndSave(oClassroom); else srvClassroom.UpdateAndSave(oClassroom); } catch (Exception ex) { ModelState.AddModelError("", "Ocorreu um erro: " + ex.Message); } } // Cria uma lista de escolas para preencher o dropdownlist var srvCollege = new CollegeService(ctx); var lstColleges = srvCollege.GetAll(); ViewBag.Colleges = new SelectList(lstColleges, "ID", "Name"); } return PartialView("_ModalForm", oClassroom); }