Beispiel #1
0
        public void RemoverRemoveLesson_ValidParameters_LessonRemoved()
        {
            // Arrange
            Creator.CreateCourse(Instances.Name, Instances.Description);
            Course course = Course.GetByID(1);

            Creator.CreateStudent(Instances.Name, Instances.Username, Instances.Password);
            Student student = Student.GetByID(2);

            course.AddStudent(student);
            Creator.CreateRoom(Instances.Name);
            List <Room> rooms = new List <Room> {
                Room.GetByID(1)
            };

            Creator.CreateLesson(course, Instances.Description, Instances.Online,
                                 Instances.Date, rooms, Instances.Filepaths);
            Lesson lesson = Lesson.GetByID(1);

            lesson.GiveAbsence(student);

            // Act
            Remover.RemoveLesson(lesson);

            // Assert
            Assert.AreEqual(0, Lesson.GetAll().Count);
            Assert.AreEqual(0, course.Lessons.Count);
            Assert.AreEqual(0, student.Absences.Count);
            Assert.AreEqual(0, rooms[0].Reservations.Count);
        }
        // private readonly CurriculumContext _db;
        // private readonly UserManager<ApplicationUser> _userManager;

        // public LessonsController(UserManager<ApplicationUser> userManager, CurriculumContext db)
        // {
        //   _userManager = userManager;
        //   _db = db;
        // }

        public ActionResult Index()
        {
            var           query = Request.QueryString.ToString();
            List <Lesson> model = Lesson.GetAll(query).ToList();

            return(View(model));
        }
Beispiel #3
0
        public void RemoverRemoveCourse_ValidParameters_CourseRemoved()
        {
            // Arrange
            Creator.CreateCourse(Instances.Name, Instances.Description);
            Course course = Course.GetByID(1);

            Creator.CreateStudent(Instances.Name, Instances.Username, Instances.Password);
            Student student = Student.GetByID(2);

            course.AddStudent(student);
            Creator.CreateTeacher(Instances.Name, Instances.Username, Instances.Password);
            Teacher teacher = Teacher.GetByID(3);

            course.AddTeacher(teacher);
            Creator.CreateLesson(course, Instances.Description, Instances.Online,
                                 Instances.Date, Instances.Rooms, Instances.Filepaths);
            Creator.CreateAssignmentDescription(course, Instances.Description, Instances.Date, Instances.Filepaths);
            Creator.CreateCourseGrade(course, student, Instances.Grade, Instances.Comment);

            // Act
            Remover.RemoveCourse(course);

            // Assert
            Assert.AreEqual(0, Course.GetAll().Count);
            Assert.AreEqual(0, student.Courses.Count);
            Assert.AreEqual(0, teacher.Courses.Count);
            Assert.AreEqual(0, Lesson.GetAll().Count);
            Assert.AreEqual(0, AssignmentDescription.GetAll().Count);
            Assert.AreEqual(0, CourseGrade.GetAll().Count);
        }
Beispiel #4
0
        public ActionResult AddLesson(int id)
        {
            Track         thisTrack = Track.GetDetails(id, "");
            List <Lesson> lessons   = Lesson.GetAll("").ToList();

            ViewBag.LessonId = new SelectList(lessons, "LessonId", "Title");
            return(View(thisTrack));
        }
Beispiel #5
0
        // GET: Lessons
        public async Task <ActionResult> Index()
        {
            var result = await Lesson.GetAll(db);

            return(View(result.Select(x => new LessonViewModels()
            {
                IdLesson = x.IdLesson, Name = x.Name
            }).ToList()));
        }
Beispiel #6
0
        public ActionResult Index()
        {
            var model = new Dictionary <string, object>()
            {
                { "Lessons", Lesson.GetAll("") },
                { "Tracks", Track.GetAll("") }
            };

            return(View(model));
        }
Beispiel #7
0
        // GET: Lessons/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var lessons = await Lesson.GetAll(db);

            LessonViewModels lessonViewModels = lessons.Where(x => x.IdLesson == id).Select(x => new LessonViewModels()
            {
                IdLesson = x.IdLesson, Name = x.Name
            }).FirstOrDefault();

            if (lessonViewModels == null)
            {
                return(HttpNotFound());
            }
            return(View(lessonViewModels));
        }