Ejemplo n.º 1
0
        public ActionResult Manter(int?id)
        {
            Teacher model;

            if (id.HasValue)
            {
                model = _servicoTeacher.GetById(id.Value);
            }
            else
            {
                model = new Teacher {
                    Person = new Person()
                };
            }

            var disciplinas = model.Courses;

            TempData[DISCIPLINA] = disciplinas.ToList();
            keepTempData();

            CarregarDropDowns(model);

            return(View(Constants.MANTER, model));
        }
Ejemplo n.º 2
0
        public JsonResult Salvar(Class model)
        {
            var jsonResult = new JsonResult();

            try
            {
                GetSelectedDiscents(model);
                model.Teacher = _servicoTeacher.GetById(model.Teacher.Id);

                _servicoClass.ValidateTurmaBusinessRules(model);
                _servicoClass.SaveAndReturn(model);
            }
            catch (Exception e)
            {
                jsonResult = e.GetType() == typeof(DuplicatedEntityException)
                    ? BuildJson(0, Messages.REGISTER_ALREADY_IN_PLACE)
                    : BuildJson(0, Messages.CLASS_STUDENT_OVERFLOW);
            }

            return(jsonResult);
        }