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); }