Beispiel #1
0
        public static List <CourseDTO> GetAllCourse(int teacherid)
        {
            using (DAL.SchoolEntities DB = new DAL.SchoolEntities())
            {
                List <CourseDTO> listCourse = new List <CourseDTO>();
                var e = DB.Courses.Where(t => t.IdTeacher == teacherid);

                foreach (var item in e)
                {
                    listCourse.Add(CourseDTO.CourseConvertDTO(item));
                }
                return(listCourse);
            }
        }
Beispiel #2
0
        public static bool createCourse(CourseDTO course)
        {
            var courseDal = CourseDTO.CourseConvertDAL(course);

            try
            {
                using (DAL.SchoolEntities DB = new DAL.SchoolEntities())
                {
                    DB.Courses.Add(courseDal);
                    DB.SaveChanges();
                    return(true);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }