// GET: Courses/Create public ActionResult Create() { AssignmentRepository assignemntRepository = new AssignmentRepository(); 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: Assignment public ActionResult AssignmentTable(string sortOrder, string searchTitle, int?page) { ViewBag.CurrentTitle = searchTitle; ViewBag.CurrentSort = sortOrder; ViewBag.TitleShort = String.IsNullOrEmpty(sortOrder) ? "TitleDesc" : ""; AssignmentRepository assignmentRepository = new AssignmentRepository(); var assignments = assignmentRepository.GetAll(); // FILTERING if (!string.IsNullOrWhiteSpace(searchTitle)) { assignments = assignments.Where(x => x.Title.ToUpper().Contains(searchTitle.ToUpper())); } // SORTING switch (sortOrder) { case "TitleDesc": assignments = assignments.OrderByDescending(x => x.Title); break; default: assignments = assignments.OrderBy(x => x.Title); break; } // PAGINATION int pageSize = 4; int pageNuber = page ?? 1; return(View(assignments.ToPagedList(pageNuber, pageSize))); }
// 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)); }
// GET: assignments public ActionResult ShowAssignments() { AssignmentRepository assignmentRepository = new AssignmentRepository(); var assignment = assignmentRepository.GetAll(); return(View(assignment.ToList())); }
public void DeleteAssignmentsTest() { var options = new DbContextOptionsBuilder <AppDBContext>() .UseInMemoryDatabase(databaseName: "AssignmentDeleteDatabase") .Options; using (var context = new AppDBContext(options)) { context.Assignment.Add(new Assignment { Id = "1", Name = "1", Description = "1" }); context.Assignment.Add(new Assignment { Id = "2", Name = "2", Description = "2" }); context.Assignment.Add(new Assignment { Id = "3", Name = "3", Description = "3" }); context.Assignment.Add(new Assignment { Id = "4", Name = "4", Description = "4" }); context.SaveChanges(); } using (var context = new AppDBContext(options)) { AssignmentRepository assignmentRepository = new AssignmentRepository(context); assignmentRepository.Delete("4"); context.SaveChanges(); List <Assignment> assignments = assignmentRepository.GetAll().ToList(); Assert.Equal(3, assignments.Count); } }
// // GET: /Assignment/ public ActionResult Index() { ViewBag.StdGroup1 = "I am Batman"; List <Assignment> assignments = new List <Assignment>(); AssignmentRepository assignmentRepository = new AssignmentRepository(); assignments.AddRange(assignmentRepository.GetAll()); return(View(assignments)); }
// // GET: /Assignment/ public ActionResult Index() { var assingments = new List <Assignment>(); var assingmentRepository = new AssignmentRepository(); assingments.AddRange(assingmentRepository.GetAll()); return(View(assingments)); }
// 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)); }
// 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)); }
// GET: Assignment public ActionResult AssignmentTable(string sortOrder, string searchTitle, string searchDescription, int?page, int?pSize) { //--------------- FILTERING type ------------------ ViewBag.CurrentTitleName = searchTitle; ViewBag.CurrentDescriptionName = searchDescription; ViewBag.CurrentSortOrder = sortOrder; ViewBag.CurrentpSize = pSize; //---------------- SORTING Parameters -------------------- ViewBag.TitleNameSortParam = String.IsNullOrEmpty(sortOrder) ? "TitleNameDesc" : ""; ViewBag.DescriptionNameSortParam = sortOrder == "DescriptionAsc" ? "DescriptionDesc" : "DescriptionAsc"; ViewBag.SubTimeSortParam = sortOrder == "SubTimeAsc" ? "SubTimeDesc" : "SubTimeAsc"; ViewBag.TNView = "badge badge-primary"; ViewBag.DNView = "badge badge-primary"; ViewBag.STView = "badge badge-primary"; AssignmentRepository assignmentRepository = new AssignmentRepository(); var assignment = assignmentRepository.GetAll(); //--------------- FILTERING check ------------------ if (!string.IsNullOrWhiteSpace(searchTitle)) { assignment = assignment.Where(x => x.Title.ToUpper().Contains(searchTitle.ToUpper())); } if (!string.IsNullOrWhiteSpace(searchDescription)) { assignment = assignment.Where(x => x.Description.ToUpper().Contains(searchDescription.ToUpper())); } //---------------- SORTING check -------------------- switch (sortOrder) { case "TitleNameDesc": assignment = assignment.OrderByDescending(x => x.Title); ViewBag.TNView = "badge badge-danger"; break; case "DescriptionAsc": assignment = assignment.OrderBy(x => x.Description); ViewBag.DNView = "badge badge-success"; break; case "DescriptionDesc": assignment = assignment.OrderByDescending(x => x.Description); ViewBag.DNView = "badge badge-danger"; break; case "SubTimeAsc": assignment = assignment.OrderBy(x => x.SubTime); ViewBag.STView = "badge badge-success"; break; case "SubTimeDesc": assignment = assignment.OrderByDescending(x => x.SubTime); ViewBag.STView = "badge badge-danger"; break; default: assignment = assignment.OrderBy(x => x.AssignmentId); ViewBag.TNView = "badge badge-success"; break; } //----------------- PAGINATION check ------------------ int pageSize = pSize ?? 5; int pageNumber = page ?? 1; return(View(assignment.ToPagedList(pageNumber, pageSize))); }
public IHttpActionResult GetAssignments() { var assignments = assignmentRepo.GetAll(); if (!assignments.Any()) { return(Content(HttpStatusCode.NotFound, "List is empty")); } return(Ok(assignments)); }
public static void AllAssignments() { AssignmentRepository assignmentRepository = new AssignmentRepository(); var assignments = assignmentRepository.GetAll(); foreach (var assignment in assignments) { Console.WriteLine("{0, -5}{1, -10}", assignment.AssignmentId, assignment.Title); } }
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: 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)); }
// 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) }); AssignmentRepository assignemntRepository = new AssignmentRepository(); 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)); }
public override void OnBeforeInsert(CommentViewModel viewModel, int?id) { if (id.HasValue) { viewModel.AssignmentId = id.Value; //EXAMPLE CODE FOR DROPDOWNS viewModel.AssignmentList = new List <SelectListItem>(); AssignmentRepository repo = new AssignmentRepository(); var allAssignments = repo.GetAll(); foreach (var assignment in allAssignments) { var selectListItem = new SelectListItem(); selectListItem.Text = assignment.Title; selectListItem.Value = assignment.Id.ToString(); viewModel.AssignmentList.Add(selectListItem); } } }
public IEnumerable <Assignment> GetAll() { return(assignmentRepo.GetAll()); }
// GET: Assignent public ActionResult AssignmentTable(string sortOrder, string searchtitle, string searchdescription, DateTime?searchminsubdatetime, DateTime?searchmaxsubdatetime, int?page, int?pSize) { ViewBag.CurrenTitle = searchtitle; ViewBag.CurrentDescription = searchdescription; ViewBag.CurrentMinSubDateTime = searchminsubdatetime; ViewBag.CurrentMaxSubDateTime = searchmaxsubdatetime; ViewBag.CurrentSortOrder = sortOrder; ViewBag.CurrentpSize = pSize; ViewBag.TitleSortParam = String.IsNullOrEmpty(sortOrder) ? "TitleDesc" : ""; ViewBag.DescriptionSortParam = sortOrder == "DescriptionAsc" ? "DescriptionDesc" : "DescriptionAsc"; ViewBag.SubDateTimeSortParam = sortOrder == "SubDateTimeAsc" ? "SubDateTimeDesc" : "SubDateTimeAsc"; ViewBag.DetailsSortParam = sortOrder == "DetailsAsc" ? "DetailsDesc" : "DetailsAsc"; ViewBag.FNView = "badge badge-primary"; ViewBag.LNView = "badge badge-primary"; ViewBag.AGView = "badge badge-primary"; ViewBag.DTView = "badge badge-primary"; AssignmentRepository assignmentRepository = new AssignmentRepository(); var assignments = assignmentRepository.GetAll(); //======================FILTERS=============================== //Filtering title if (!string.IsNullOrWhiteSpace(searchtitle)) { assignments = assignments.Where(x => x.Title.ToUpper().Contains(searchtitle.ToUpper())); } //Filtering description if (!string.IsNullOrWhiteSpace(searchdescription)) { assignments = assignments.Where(x => x.Description.ToUpper().Contains(searchdescription.ToUpper())); } //Filtering Minimum submission date if (!(searchminsubdatetime is null)) //40 { assignments = assignments.Where(x => x.SubDateTime >= searchminsubdatetime); } //Filtering Maximum submission date if (!(searchmaxsubdatetime is null)) //50 { assignments = assignments.Where(x => x.SubDateTime <= searchmaxsubdatetime); } //Sorting switch (sortOrder) { case "TitleDesc": assignments = assignments.OrderByDescending(x => x.Title); ViewBag.FNView = "badge badge-danger"; break; case "StreamAsc": assignments = assignments.OrderBy(x => x.Description); ViewBag.LNView = "badge badge-success"; break; case "SubDateTimeAsc": assignments = assignments.OrderBy(x => x.SubDateTime); ViewBag.AGView = "badge badge-success"; break; case "SubDateTimDesc": assignments = assignments.OrderByDescending(x => x.SubDateTime); ViewBag.AGView = "badge badge-danger"; break; } int pageSize = pSize ?? 5; int pageNumber = page ?? 1; //nullable coehelesing operator return(View(assignments.ToPagedList(pageNumber, pageSize))); }
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)); } } }
public List <Assignment> GetAll(Expression <Func <Assignment, bool> > filter) { return(repository.GetAll(filter)); }