// GET: Trainers
        public ActionResult Index()
        {
            var trainers = trainerRepository.GetAll();

            ViewBag.TrainersCount = trainers.Count();
            return(View(trainers));
        }
        // GET: Stats
        public ActionResult Index()
        {
            StatsViewModel vm = new StatsViewModel();

            CourseRepository courseRepository = new CourseRepository();
            var courses     = courseRepository.GetAll();
            int courseCount = courses.Count();

            vm.CoursesCount = courseCount;

            TrainerRepository trainerRepository = new TrainerRepository();
            var trainers     = trainerRepository.GetAll();
            int trainerCount = trainers.Count();

            vm.TrainersCount = trainerCount;

            AssignmentRepository assignmentRepository = new AssignmentRepository();
            var assignments     = assignmentRepository.GetAll();
            int assignmentCount = assignments.Count();

            vm.AssignmentsCount = assignmentCount;

            StudentRepository studentRepository = new StudentRepository();
            var students     = studentRepository.GetAll();
            int studentCount = students.Count();

            vm.StudentsCount = studentCount;

            vm.CourseTable = courses;

            return(View(vm));
        }
        public ActionResult ShowTrainersPerCourse()
        {
            TrainerRepository trainerRepository = new TrainerRepository();
            var trainers = trainerRepository.GetAll();

            return(View(trainers));
        }
Esempio n. 4
0
        // GET: Courses/Create
        public ActionResult Create()
        {
            AssignemntRepository assignemntRepository = new AssignemntRepository();

            ViewBag.SelectedAssignmentsId = assignemntRepository.GetAll().Select(x => new SelectListItem()
            {
                Value = x.AssignmentId.ToString(),
                Text  = x.Title
            });

            TrainerRepository trainerRepository = new TrainerRepository();

            ViewBag.SelectedTrainersId = trainerRepository.GetAll().Select(x => new SelectListItem()
            {
                Value = x.TrainerId.ToString(),
                Text  = x.LastName
            });

            StudentRepository studentRepository = new StudentRepository();

            ViewBag.SelectedStudentsId = studentRepository.GetAll().Select(x => new SelectListItem()
            {
                Value = x.StudentId.ToString(),
                Text  = x.LastName
            });

            return(View());
        }
        // GET: Stats
        public ActionResult Index()
        {
            StatsViewModel vm = new StatsViewModel();

            StudentRepository studentRepository = new StudentRepository();
            var students = studentRepository.GetAll();

            CourseRepository courseRepository = new CourseRepository();
            var courses = courseRepository.GetAll();

            TrainerRepository trainerRepository = new TrainerRepository();
            var trainers = trainerRepository.GetAll();

            AssignmentRepository assignmentRepository = new AssignmentRepository();
            var assignments = assignmentRepository.GetAll();

            vm.StudentsCount    = students.Count();
            vm.CoursesCount     = courses.Count();
            vm.TrainersCount    = trainers.Count();
            vm.AssignmentsCount = assignments.Count();

            //Grouping Course Student
            vm.StudentsPerCourse = students
                                   .SelectMany(x => x.Courses.Select(y => new
            {
                Key   = y,
                Value = x
            }))
                                   .GroupBy(y => y.Key, x => x.Value);

            //Grouping Course Trainer
            vm.TrainersPerCourse = trainers
                                   .SelectMany(x => x.Courses.Select(y => new
            {
                Key   = y,
                Value = x
            }))
                                   .GroupBy(y => y.Key, x => x.Value);

            //Grouping Course Assignment
            vm.AssignmentPerCourse = courses
                                     .SelectMany(x => x.Assignments.Select(y => new
            {
                Key   = x,
                Value = y
            }))
                                     .GroupBy(y => y.Key, x => x.Value);

            vm.Students    = students;
            vm.Courses     = courses;
            vm.Assignments = assignments;



            return(View(vm));
        }
Esempio n. 6
0
        // GET: Stats
        public ActionResult Index()
        {
            StatsViewModel statsView = new StatsViewModel();

            StudentRepository studentRepository = new StudentRepository();
            var students = studentRepository.GetAll();
            TrainerRepository trainerRepository = new TrainerRepository();
            var trainers = trainerRepository.GetAll();
            CourseRepository courseRepository = new CourseRepository();
            var courses = courseRepository.GetAll();
            AssignmentRepository assignmentRepository = new AssignmentRepository();
            var assignments = assignmentRepository.GetAll();


            statsView.StudentsCount    = students.Count();
            statsView.TrainersCount    = trainers.Count();
            statsView.CoursesCount     = courses.Count();
            statsView.AssignmentsCount = assignments.Count();

            //Grouping Students Per Course
            statsView.StudentsPerCourse = from student in students
                                          group student by student.Course into x
                                          orderby x.Key
                                          select x;

            //Grouping Trainers Per Course
            statsView.TrainersPerCourse = trainers
                                          .SelectMany(x => x.Courses.Select(y => new
            {
                Key   = y,
                Value = x
            })).GroupBy(y => y.Key, x => x.Value);

            //Grouping Assignments Per Course
            statsView.AssignmentPerCourse = assignments
                                            .SelectMany(x => x.Courses.Select(y => new
            {
                Key   = y,
                Value = x
            })).GroupBy(y => y.Key, x => x.Value);

            //Grouping Assignments Per Student
            statsView.AssignmentPerStudent = assignments
                                             .SelectMany(x => x.MarkAssignments.Select(y => new
            {
                Key   = x,
                Value = y
            })).GroupBy(x => x.Key, y => y.Value);


            statsView.Students    = students;
            statsView.Courses     = courses;
            statsView.Assignments = assignments;

            return(View(statsView));
        }
        public static void AllTrainers()
        {
            TrainerRepository trainerRepository = new TrainerRepository();

            var trainers = trainerRepository.GetAll();

            foreach (var trainer in trainers)
            {
                Console.WriteLine("{0, -5}{1, -10}", trainer.TrainerId, trainer.FirstName);
            }
        }
        public StudentCourseTrainerAssignment()
        {
            StudentRepository    studentRepository    = new StudentRepository();
            CourseRepository     courseRepository     = new CourseRepository();
            TrainerRepository    trainerRepository    = new TrainerRepository();
            AssignmentRepository assignmentRepository = new AssignmentRepository();

            Students    = studentRepository.GetAll();
            Courses     = courseRepository.GetAll();
            Trainers    = trainerRepository.GetAll();
            Assignments = assignmentRepository.GetAll();
        }
        // GET: Trainers
        public ActionResult TrainerTable(string sortOrder, string searchfirstname, string searchlastname, string searchsubject, int?page)
        {
            ViewBag.CurrentFirstName = searchfirstname;
            ViewBag.CurrentLastName  = searchlastname;
            ViewBag.CurrentSubject   = searchsubject;
            ViewBag.CurrentSortOrder = sortOrder;

            ViewBag.FirstNameSortParam = String.IsNullOrEmpty(sortOrder) ? "FirstNameDesc" : "";

            ViewBag.LastNameSortParam = sortOrder == "LastNameAsc" ? "LastNameDesc" : "LastNameAsc";
            ViewBag.SubjectSortParam  = sortOrder == "SubjectAsc" ? "SubjectDesc" : "SubjectAsc";

            ViewBag.FNView = "badge badge-primary";
            ViewBag.LNView = "badge badge-primary";


            TrainerRepository trainerRepository = new TrainerRepository();
            var trainers = trainerRepository.GetAll();

            //======================FILTERS===============================
            //Filtering  FirstName
            if (!string.IsNullOrWhiteSpace(searchfirstname))
            {
                trainers = trainers.Where(x => x.FirstName.ToUpper().Contains(searchfirstname.ToUpper()));
            }
            //Filtering  LastName
            if (!string.IsNullOrWhiteSpace(searchlastname))
            {
                trainers = trainers.Where(x => x.LastName.ToUpper().Contains(searchlastname.ToUpper()));
            }
            switch (sortOrder)
            {
            case "FirstNameDesc": trainers = trainers.OrderByDescending(x => x.FirstName); ViewBag.FNView = "badge badge-danger"; break;

            case "LastNameAsc": trainers = trainers.OrderBy(x => x.LastName); ViewBag.LNView = "badge badge-success"; break;

            case "LastNameDesc": trainers = trainers.OrderByDescending(x => x.LastName); ViewBag.LNView = "badge badge-danger"; break;

            case "SubjectAsc": trainers = trainers.OrderBy(x => x.Subject); ViewBag.LNView = "badge badge-success"; break;

            case "SubjectDesc": trainers = trainers.OrderByDescending(x => x.Subject); ViewBag.LNView = "badge badge-danger"; break;


            default: trainers = trainers.OrderBy(x => x.FirstName); ViewBag.FNView = "badge badge-success"; break;
            }

            int pageSize   = 10;
            int pageNumber = page ?? 1;  //nullable coehelesing operator


            return(View(trainers.ToPagedList(pageNumber, pageSize)));
        }
        // GET: Statistics
        public ActionResult ShowAllStatistics()
        {
            StatisticsViewModel vm = new StatisticsViewModel();

            CourseRepository courseRepository = new CourseRepository();
            var courses = courseRepository.GetAll();
            StudentRepository studentRepository = new StudentRepository();
            var students = studentRepository.GetAll();
            TrainerRepository trainerRepository = new TrainerRepository();
            var trainers = trainerRepository.GetAll();
            AssignmentRepository assignmentRepository = new AssignmentRepository();
            var assignments = assignmentRepository.GetAll();


            vm.NoOfCourses     = courses.Count();
            vm.NoOfStudents    = students.Count();
            vm.NoOfTrainers    = trainers.Count();
            vm.NoOfAssignments = assignments.Count();

            vm.Courses     = courses;
            vm.Trainers    = trainers;
            vm.Students    = students;
            vm.Assignments = assignments;


            //------------------------------------ Μεση βαθμολογία ανά Course (Στην κονσολα τρέχει...Στο browser δεν περνάει σωστά το vm )
            List <double> avgGradPerCourse = new List <double>();

            double[] avg = new double[6];
            foreach (var co in courses)
            {
                Console.WriteLine(co.Title);
                double sum   = 0;
                int    count = 0;

                foreach (var item in co.StudentAssignments)
                {
                    Console.WriteLine("\t\t" + item.Assignment.Title);
                    Console.WriteLine("\t\t\t" + item.Grade);
                    sum    = sum + item.Grade;
                    count += 1;
                }
                avgGradPerCourse.Add((sum / count));
            }
            vm.AvgGradePerCourse = avgGradPerCourse;

            return(View(vm));
        }
Esempio n. 11
0
        // GET: Courses/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Course course = courseRepository.GetById(id);

            if (course == null)
            {
                return(HttpNotFound());
            }

            TrainerRepository trainerRepository = new TrainerRepository();

            ViewBag.SelectedTrainersId = trainerRepository.GetAll().Select(x => new SelectListItem()
            {
                Value    = x.TrainerId.ToString(),
                Text     = x.LastName,
                Selected = course.Trainers.Any(y => y.TrainerId == x.TrainerId)
            });

            StudentRepository studentRepository = new StudentRepository();

            ViewBag.SelectedStudentsId = studentRepository.GetAll().Select(x => new SelectListItem()
            {
                Value    = x.StudentId.ToString(),
                Text     = x.LastName,
                Selected = course.Students.Any(y => y.StudentId == x.StudentId)
            });

            AssignemntRepository assignemntRepository = new AssignemntRepository();

            ViewBag.SelectedAssignmentsId = assignemntRepository.GetAll().Select(x => new SelectListItem()
            {
                Value    = x.AssignmentId.ToString(),
                Text     = x.Title,
                Selected = course.Assignments.Any(y => y.AssignmentId == x.AssignmentId)
            });

            return(View(course));
        }
Esempio n. 12
0
        // GET: Trainer
        public ActionResult TrainerTable(string sortOrder, string searchlastname, string searchfirstname, int?page)
        {
            ViewBag.CurrentFirstName = searchfirstname;
            ViewBag.CurrentLastName  = searchlastname;

            ViewBag.FirstNameShort = String.IsNullOrEmpty(sortOrder) ? "FirstNameDesc" : "";
            ViewBag.LastNameSort   = sortOrder == "LastNameAsc" ? "LastNameDesc" : "LastNameAsc";

            TrainerRepository trainerRepository = new TrainerRepository();
            var trainers = trainerRepository.GetAll();

            // FILTERING
            if (!string.IsNullOrWhiteSpace(searchlastname))
            {
                trainers = trainers.Where(x => x.LastName.ToUpper().Contains(searchlastname.ToUpper()));
            }

            // SORTING
            switch (sortOrder)
            {
            case "FirstNameDesc": trainers = trainers.OrderByDescending(x => x.FirstName); break;

            case "LastNameAsc": trainers = trainers.OrderBy(x => x.LastName); break;

            case "LastNameDesc": trainers = trainers.OrderByDescending(x => x.LastName); break;

            default: trainers = trainers.OrderBy(x => x.FirstName); break;
            }

            // PAGINATION
            int pageSize  = 4;
            int pageNuber = page ?? 1;


            return(View(trainers.ToPagedList(pageNuber, pageSize)));
        }
Esempio n. 13
0
        public ActionResult <IEnumerable <Trainer> > GetAllTrainers()
        {
            var repo = new TrainerRepository();

            return(repo.GetAll());
        }
Esempio n. 14
0
 public ActionResult <IEnumerable <Trainer> > GetAllTrainers()
 {
     return(_repo.GetAll());
 }
Esempio n. 15
0
        // GET: Trainer
        public ActionResult TrainerTable(string sortOrder, string searchFirstName, string searchLastName, int?searchMinAge, int?searchMaxAge, string searchCountry, double?searchMinSalary, double?searchMaxSalary, int?page, int?pSize)
        {
            //--------------- FILTERING type ------------------
            ViewBag.CurrentFirstName = searchFirstName;
            ViewBag.CurrentLastName  = searchLastName;
            ViewBag.CurrentMinAge    = searchMinAge;
            ViewBag.CurrentMaxAge    = searchMaxAge;
            ViewBag.CurrentCountry   = searchCountry;
            ViewBag.CurrentMinSalary = searchMinSalary;
            ViewBag.CurrentMaxSalary = searchMaxSalary;
            ViewBag.CurrentSortOrder = sortOrder;
            ViewBag.CurrentpSize     = pSize;


            //---------------- SORTING Parameters --------------------
            ViewBag.FirstNameSortParam = String.IsNullOrEmpty(sortOrder) ? "FirstNameDesc" : "";
            ViewBag.LastNameSortParam  = sortOrder == "LastNameAsc" ? "LastNameDesc" : "LastNameAsc";
            ViewBag.AgeSortParam       = sortOrder == "AgeAsc" ? "AgeDesc" : "AgeAsc";
            ViewBag.CountrySortParam   = sortOrder == "CountryAsc" ? "CountryDesc" : "CountryAsc";
            ViewBag.SalarySortParam    = sortOrder == "SalaryAsc" ? "SalaryDesc" : "SalaryAsc";


            ViewBag.FNView = "badge badge-primary";
            ViewBag.LNView = "badge badge-primary";
            ViewBag.AView  = "badge badge-primary";
            ViewBag.CView  = "badge badge-primary";
            ViewBag.SView  = "badge badge-primary";


            var trainer = trainerRepository.GetAll();

            //--------------- FILTERING check ------------------
            if (!string.IsNullOrWhiteSpace(searchFirstName))
            {
                trainer = trainer.Where(x => x.FirstName.ToUpper().Contains(searchFirstName.ToUpper()));
            }
            if (!string.IsNullOrWhiteSpace(searchLastName))
            {
                trainer = trainer.Where(x => x.LastName.ToUpper().Contains(searchLastName.ToUpper()));
            }
            if (!(searchMinAge is null))
            {
                trainer = trainer.Where(x => x.Age <= searchMinAge);
            }
            if (!(searchMaxAge is null))
            {
                trainer = trainer.Where(x => x.Age >= searchMaxAge);
            }
            if (!(searchMinSalary is null))
            {
                trainer = trainer.Where(x => x.Salary <= searchMinSalary);
            }
            if (!(searchMaxSalary is null))
            {
                trainer = trainer.Where(x => x.Salary >= searchMaxSalary);
            }


            //---------------- SORTING check --------------------
            switch (sortOrder)
            {
            case "FirstNameDesc": trainer = trainer.OrderByDescending(x => x.FirstName); ViewBag.FNView = "badge badge-danger"; break;

            case "LastNameAsc": trainer = trainer.OrderBy(x => x.LastName); ViewBag.LNView = "badge badge-success"; break;

            case "LastNameDesc": trainer = trainer.OrderByDescending(x => x.LastName); ViewBag.LNView = "badge badge-danger"; break;

            case "AgeAsc": trainer = trainer.OrderBy(x => x.Age); ViewBag.AView = "badge badge-success"; break;

            case "AgeDesc": trainer = trainer.OrderByDescending(x => x.Age); ViewBag.AView = "badge badge-danger"; break;

            case "CountryAsc": trainer = trainer.OrderBy(x => x.Country); ViewBag.CView = "badge badge-success"; break;

            case "CountryDesc": trainer = trainer.OrderByDescending(x => x.Country); ViewBag.CView = "badge badge-danger"; break;

            case "SalaryAsc": trainer = trainer.OrderBy(x => x.Salary); ViewBag.SView = "badge badge-success"; break;

            case "SalaryDesc": trainer = trainer.OrderByDescending(x => x.Salary); ViewBag.SView = "badge badge-danger"; break;

            default: trainer = trainer.OrderBy(x => x.TrainerId); ViewBag.FNView = "badge badge-success"; break;
            }

            //----------------- PAGINATION check ------------------

            int pageSize   = pSize ?? 5;
            int pageNumber = page ?? 1;   //nullable coehelesing operator

            return(View(trainer.ToPagedList(pageNumber, pageSize)));
        }
Esempio n. 16
0
        public List <Trainer> GetAll()
        {
            List <Trainer> trainerList = _trainerRepository.GetAll();

            return(trainerList);
        }
        // GET: Trainers
        public ActionResult ShowTrainers(string sortOrder, string searchFirstName, string searchLastName, string searchSubject, int?page, int?itemsPerPage)
        {
            ViewBag.FirstNameSort = String.IsNullOrEmpty(sortOrder) ? "FirstNameDesc" : "";
            ViewBag.LastNameSort  = sortOrder == "LastNameAsc" ? "LastNameDesc" : "LastNameAsc";
            ViewBag.SubjectSort   = sortOrder == "SubjAsc" ? "SubjDesc" : "SubjAsc";
            ViewBag.SortOrder     = sortOrder;

            ViewBag.SearchdFirstName = searchFirstName;
            ViewBag.SearchedLastName = searchLastName;
            ViewBag.SearchedSubject  = searchSubject;

            ViewBag.CurrentPage = page;
            ViewBag.PageSize    = itemsPerPage;



            TrainerRepository trainerRepository = new TrainerRepository();
            var trainers = trainerRepository.GetAll();


            // ------------------------ Ταξινόμηση φθίνουσα/αύξουσα ----------------------------------------------------
            switch (sortOrder)
            {
            case "FirstNameDesc": trainers = trainers.OrderByDescending(x => x.FirstName);
                break;

            case "LastNameAsc":
                trainers = trainers.OrderBy(x => x.LastName);
                break;

            case "LastNameDesc":
                trainers = trainers.OrderByDescending(x => x.LastName);
                break;

            case "SubjAsc":
                trainers = trainers.OrderBy(x => x.Subject);
                break;

            case "SubjDesc":
                trainers = trainers.OrderByDescending(x => x.Subject);
                break;


            default: trainers = trainers.OrderBy(x => x.FirstName);
                break;
            }
            //---------------------------------- Φιλτράρισμα ------------------------------------------
            if (!string.IsNullOrWhiteSpace(searchFirstName))
            {
                trainers = trainers.Where(x => x.FirstName.ToUpper().Contains(searchFirstName.ToUpper()));
            }

            if (!string.IsNullOrWhiteSpace(searchLastName))
            {
                trainers = trainers.Where(x => x.LastName.ToUpper().Contains(searchLastName.ToUpper()));
            }

            if (!(searchSubject is null))
            {
                trainers = trainers.Where(x => x.Subject.ToUpper().Contains(searchSubject.ToUpper()));
            }

            int pageSize = itemsPerPage ?? 5;
            int pageNum  = page ?? 1;


            return(View(trainers.ToPagedList(pageNum, pageSize)));
        }
        // GET: Trainers
        public ActionResult Index()
        {
            var trainers = trainerRepository.GetAll();

            return(View(trainers));
        }
        static void Main(string[] args)
        {
            using (MyDatabase db = new MyDatabase())
            {
                TrainerRepository    trainerRepository        = new TrainerRepository();
                StudentRepository    studentRepository        = new StudentRepository();
                AssignmentRepository assignmentRepository     = new AssignmentRepository();
                CourseRepository     courseRepository         = new CourseRepository();
                StudAssignRepository studAssignmentRepository = new StudAssignRepository();

                var studentlist    = studentRepository.GetAll();
                var trainerlist    = trainerRepository.GetAll();
                var assignmentlist = assignmentRepository.GetAll();
                var courselist     = courseRepository.GetAll();
                var studassignlist = studAssignmentRepository.GetAll();

                //======================   Grades per student
                foreach (var student in studentlist)
                {
                    Console.WriteLine(student.FirstName);
                    foreach (var assignment in student.StudentAssignments)
                    {
                        Console.WriteLine("\t\t" + assignment.Assignment.Title + " " + assignment.Grade);
                    }
                }

                //=============================== Grades per sudent per course
                Console.WriteLine("====================GRADES PER COURSE PER STUDENTS==================================");
                foreach (var studas in studassignlist)
                {
                    Console.WriteLine(studas.Student.FirstName + " " + studas.Course.Title);
                    Console.WriteLine("\t\t\t\t" + studas.Assignment.Title + " " + studas.Grade);
                }


                foreach (var stude in studentlist)
                {
                    Console.WriteLine($"Student: {stude.LastName}");

                    foreach (var cours in stude.Courses)
                    {
                        Console.Write("\t\t");
                        Console.WriteLine("Course: " + cours.Title);
                        foreach (var assign in cours.Assignments)
                        {
                            Console.Write("\t\t\t\t");
                            Console.WriteLine("Assignment title: " + assign.Title);
                        }
                    }
                    Console.WriteLine();
                }



                //Console.WriteLine("========================================================================");

                foreach (var course in courselist)
                {
                    Console.Write("In " + course.Title);
                    Console.WriteLine(" are enrolled " + course.Students.Count() + " students");
                    foreach (var studentCourse in course.Students)
                    {
                        Console.Write("\t\t");
                        Console.WriteLine(studentCourse.FirstName + " " + studentCourse.LastName);
                    }
                    Console.WriteLine();
                }
                //================================== Assignments per course===========================
                foreach (var item in courselist)
                {
                    Console.WriteLine(item.Title);
                    foreach (var item2 in item.Assignments)
                    {
                        Console.WriteLine("\t\t\t" + item2.Title);
                    }
                }

                //=========================================== Students per course per assignment ==============================


                foreach (var stud in studentlist)
                {
                    Console.WriteLine(stud.FirstName);
                    foreach (var item in stud.StudentAssignments)
                    {
                        Console.WriteLine("\t\t" + item.Assignment.Title);
                        Console.WriteLine("\t\t\t" + item.Course.Title);
                    }
                }

                //=========================================== Average grade per course ==============================

                List <double> avgGradPerCourse = new List <double>();

                foreach (var co in courselist)
                {
                    Console.WriteLine(co.Title);
                    double sum   = 0;
                    int    count = 0;
                    foreach (var item in co.StudentAssignments)
                    {
                        //Console.WriteLine("\t\t" + item.Assignment.Title);
                        //Console.WriteLine("\t\t\t" + item.Grade);
                        sum    = sum + item.Grade;
                        count += 1;
                    }
                    avgGradPerCourse.Add(sum / count);  //λιστα με τη μεση βαθμολογία για κάθε μάθημα
                    Console.WriteLine("Average grade is: " + (sum / count));
                }
            }
        }