Example #1
0
        public void GetAllExercises_ReturnsAllExercises()
        {
            // Act
            var exercises = _exerciseRepository.GetAllExercises();

            // Assert
            Assert.NotNull(exercises);
        }
Example #2
0
        public StudentEditViewModel(string connectionString)
        {
            _connectionString = connectionString;

            //student = StudentRepository.GetOneStudent(studentId);

            // Get the exercises that are currently assigned to this student
            // The student model already has a list for this!
            Student.StudentExs = GetAssignedExercisesByStudent(studentId);

            allExercises = ExerciseRepository.GetAllExercises()
                           .Select(singleExercise => new SelectListItem()
            {
                Text     = singleExercise.Name,
                Value    = singleExercise.id.ToString(),
                Selected = Student.StudentExs.Find(assignedExercise => assignedExercise.id == singleExercise.id) != null
            })
                           .ToList();

            //Query the database to get all cohorts
            Cohorts = GetAllCohorts()
                      .Select(cohort => new SelectListItem()
            {
                Text  = cohort.CohortName,
                Value = cohort.CohortId.ToString()
            })
                      .ToList();

            // Add an option with instructions for how to use the dropdown
            Cohorts.Insert(0, new SelectListItem
            {
                Text  = "Choose a cohort",
                Value = "0"
            });
        }
        static void Main(string[] args)
        {
            ExerciseRepository ERepo = new ExerciseRepository();
            var EList = ERepo.GetAllExercises();

            foreach (var item in EList)
            {
                Console.WriteLine($"{item.Name}, written in {item.Language}");
            }


            Exercise newExercise = new Exercise()
            {
                Name     = "Food",
                Language = "JS"
            };


            ERepo.AddExercise(newExercise);

            var EJSList = ERepo.GetAllJSExercises();

            foreach (var item in EJSList)
            {
                Console.WriteLine($"{item.Name}, written in {item.Language}");
            }
        }
        // GET: Exercises
        public ActionResult Index(string _orderBy)
        {
            var exercises = ExerciseRepository.GetAllExercises(_orderBy);

            return(View(exercises));
        }
Example #5
0
 public IActionResult GetAll()
 {
     return(Ok(_repository.GetAllExercises()));
 }
Example #6
0
        static void Main(string[] args)
        {
            //Exercise
            var exerciseRepo = new ExerciseRepository();
            var allExercises = exerciseRepo.GetAllExercises();

            Console.WriteLine("All Exercises--");
            foreach (var exercise in allExercises)
            {
                Console.WriteLine($"{exercise.Name} id-{exercise.Id}");
            }
            Console.WriteLine("------------------");

            //Filter Exercise
            Console.WriteLine("Find exercises by language?");
            var filterLanguage   = Console.ReadLine();
            var filteredExercise = exerciseRepo.GetFilteredExercises(filterLanguage);

            Console.WriteLine("All Filtered Exercises--");
            foreach (var exercise in filteredExercise)
            {
                Console.WriteLine($"{exercise.Name} - {exercise.Language}");
            }
            Console.ReadLine();
            Console.WriteLine("------------------");
            //Add Exercise
            var newExercise = new Exercise();

            Console.WriteLine("What exercise do you want to add?");
            newExercise.Name = Console.ReadLine();
            Console.WriteLine("What language do you have to work?");
            newExercise.Language = Console.ReadLine();

            exerciseRepo.AddExercise(newExercise);
            Console.WriteLine("------------------");
            //Instructor with Cohort
            var instructorRepo = new InstructorRepository();
            var allInstructors = instructorRepo.GetAllIntructors();

            Console.WriteLine("All Intructors with cohort--");
            foreach (var instructor in allInstructors)
            {
                Console.WriteLine($"{instructor.FirstName} {instructor.LastName} is the instructor for {instructor.Cohort.Name}");
            }
            Console.WriteLine("------------------");

            //Add Instructor
            var newInstructor = new Instructor();

            Console.WriteLine("What is your new instructor first name?");
            newInstructor.FirstName = Console.ReadLine();
            Console.WriteLine("What is your new instructor last name?");
            newInstructor.LastName = Console.ReadLine();
            Console.WriteLine("What is your new instructor slack handle?");
            newInstructor.SlackHandle = Console.ReadLine();
            Console.WriteLine("Where is your new instructor assigned?");

            newInstructor.Cohort.Id = Convert.ToInt32(Console.ReadLine());

            instructorRepo.AddInstructor(newInstructor);
            Console.WriteLine("------------------");
            //List Of Students
            var studentRepo = new StudentRepository();
            var allStudents = studentRepo.GetAllStudents();

            Console.WriteLine("List of Students------");
            foreach (var student in allStudents)
            {
                Console.WriteLine($"{student.FirstName} {student.LastName} who's (id) is {student.Id} is in {student.Cohort.Name}");
            }
            Console.WriteLine("------------------");

            //Student by Id
            Console.WriteLine("Enter student id to choose student");
            var studentById = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("Enter exercise id to choose student");
            var exerciseById = Convert.ToInt32(Console.ReadLine());

            studentRepo.AddExercise(studentById, exerciseById);
            Console.ReadLine();

            Console.WriteLine("------------------");
            // Get all exercise by StudentId
            Console.WriteLine("Choose Student By Id");
            var studentWithExercise  = Convert.ToInt32(Console.ReadLine());
            var studentWithExercises = studentRepo.GetStudentById(studentWithExercise);



            foreach (var studentExercise in studentWithExercises.Exercise)
            {
                Console.WriteLine($"{studentWithExercises.FirstName} {studentWithExercises.LastName} in {studentWithExercises.Cohort.Name} is working on {studentExercise.Name}");
            }

            Console.ReadLine();
        }