コード例 #1
0
        private static void ValidExists(Discipline discipline)
        {
            try
            {
                using (DisciplineDao dao = new DisciplineDao())
                    dao.FindByPk(discipline.Code, discipline.Period.Graduation.Id);

                throw new Exception("Já existe uma disciplina com esse código nesse curso");
            }
            catch (EntityNotFoundException e) { /* Entity not found, keep swimming! */ }
        }
コード例 #2
0
        public void Page_Init(object sender, EventArgs e)
        {
            try
            {
                int    graduationId = -1;
                string disciplineCode;
                int.TryParse(Request.Params["Graduation"], out graduationId);
                disciplineCode = Request.Params["Discipline"] ?? string.Empty;

                using (DisciplineDao dao = new DisciplineDao())
                    Discipline = dao.FindByPk(disciplineCode, graduationId);
            }
            catch (EntityNotFoundException ex)
            {
                throw new HttpException(404, ex.Message);
            }
        }