public void createStudentGroups() { int size = 0; List <Combination> combs = new List <Combination>(); List <Subject> .Enumerator subjectIterator = subjectsIncluded.GetEnumerator(); while (subjectIterator.MoveNext()) { Subject subject = subjectIterator.Current; List <Combination> .Enumerator combIterator = combinations.GetEnumerator(); while (combIterator.MoveNext()) { Combination combination = (Combination)combIterator.Current; List <string> subjects = combination.getSubjects(); List <string> .Enumerator subjectItr = subjects.GetEnumerator(); while (subjectItr.MoveNext()) { if (subjectItr.Current.Equals(subject.getSubjectName(), System.StringComparison.OrdinalIgnoreCase)) { size = size + combination.getSizeOfClass(); if (!combs.Contains(combination))//.getSubjects())) { combs.Add(combination); } } } } StudentGroups studentGroup = new StudentGroups(this.courseName + "/" + subject.getSubjectName(), subject.getNumberOfLecturesPerWeek(), size, combs, subject.getSubjectName(), subject.isIslab(), subject.getDepartment()); studentGroups.Add(studentGroup); size = 0; } }
public async Task <IActionResult> PutStudentGroups(int id, StudentGroups studentGroups) { if (id != studentGroups.UserId) { return(BadRequest()); } _context.Entry(studentGroups).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StudentGroupsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult AddStudent() { StudentGroups model = new StudentGroups(); model.Groups = groupManager.GetGroups().ToList(); return(View(model)); }
public void ConnectStudentWithGroup(string login, int groupId) { Users student = new Users(); StudentGroups sg = new StudentGroups(); using (ElectronicalJournalContext db = new ElectronicalJournalContext()) { var st = from us in db.Users where us.Login == login select new Users { UserId = us.UserId, FirstName = us.FirstName, MiddleName = !string.IsNullOrEmpty(us.MiddleName) ? us.MiddleName : string.Empty, LastName = us.LastName, Login = us.Login, PasswordHash = us.PasswordHash, PasswordSalt = us.PasswordSalt, AccessLevelId = us.AccessLevelId, Email = us.Email, Phone = us.Phone }; foreach (Users item in st) { student = item; } sg.GroupId = groupId; sg.UserId = student.UserId; db.StudentGroups.Add(sg); db.SaveChanges(); } }
public ActionResult EditStudent(int id) { Student student = studManager.GetStudentByID(id); if (student == null) { return(HttpNotFound()); } StudentGroups model = new StudentGroups(); model.Name = student.Name; model.Age = student.Age; model.GroupId = student.GroupId; model.Groups = groupManager.GetGroups().ToList(); return(View(model)); }
public async Task <IActionResult> OnGetAsync(DateTime?date) { if (!date.HasValue) { return(RedirectToPage("./Index", new { date = DateTime.Now.ToString("yyyy-M-d") })); } CurrentPeriod = Period.CreateCurrentlyActivePeriodBy(DateTime.Today).Value; var groups = await _context.Groups .OrderByDescending(g => g.Period) .ToListAsync(); StudentGroups = groups.Where(g => g.Period.IsVeryOldDate).ToList(); StudentGroups.AddRange(groups.Where(g => !g.Period.IsVeryOldDate).ToList()); return(Page()); }
public void setTimeTable(List <StudentGroups> studentGroups2, List <ClassRoom> rooms2, string str) { // TODO Auto-generated method stub studentGroups2.Shuffle(); Stack <Lecture> lecturesStack = new Stack <Lecture>(); for (var sdtGrpIterator = studentGroups2.GetEnumerator(); sdtGrpIterator.MoveNext(); ) { StudentGroups studentGrp = sdtGrpIterator.Current; string subject = studentGrp.getSubjectName(); int noOfLectures = studentGrp.getNoOfLecturePerWeek(); for (int i = 0; (i < noOfLectures); i++) { classes.Shuffle(); var classIterator = this.classes.GetEnumerator(); while (classIterator.MoveNext()) { Lecture lecture = classIterator.Current; if (lecture.getSubject().Equals(subject, System.StringComparison.InvariantCultureIgnoreCase)) { Lecture mainLecture = new Lecture(lecture.getProfessor(), lecture.getSubject()); mainLecture.setStudentGroup(studentGrp); lecturesStack.Push(mainLecture); break; } } } } while (lecturesStack.Count > 0) { lecturesStack.Shuffle(); Lecture lecture2 = lecturesStack.Pop(); if (str.Equals("theory", StringComparison.InvariantCultureIgnoreCase)) { this.placeTheoryLecture(lecture2, rooms2); } if (str.Equals("practical", StringComparison.InvariantCultureIgnoreCase)) { this.placePracticalLecture(lecture2, rooms2); } } }
public StudentGroups AddGroup(string name, string discription) { using (var db = CreateDbContext()) { var copy = db.StudentGroups.FirstOrDefault(x => x.Name == name); if (copy != null) { return(null); } var data = new StudentGroups() { Name = name, Discription = discription }; db.StudentGroups.Add(data); db.SaveChanges(); return(data); } }
public async Task <ActionResult <StudentGroups> > PostStudentGroups(StudentGroups studentGroups) { _context.StudentGroups.Add(studentGroups); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (StudentGroupsExists(studentGroups.UserId)) { return(Conflict()); } else { throw; } } return(CreatedAtAction("GetStudentGroups", new { id = studentGroups.UserId }, studentGroups)); }
public void EditStudent(FullInfoStudent student) { Users editUser = student; StudentGroups editSGUser = null; using (ElectronicalJournalContext db = new ElectronicalJournalContext()) { var studGroup = from sg in db.StudentGroups where sg.UserId == editUser.UserId select new StudentGroups { StudentGroupId = sg.StudentGroupId, UserId = sg.UserId, GroupId = sg.GroupId }; foreach (StudentGroups item in studGroup) { editSGUser = item; } if (editSGUser == null && student.GroupId != null) { StudentGroups sg = new StudentGroups(); sg.GroupId = student.GroupId; sg.UserId = student.UserId; db.StudentGroups.Add(sg); } else if (editSGUser == null) { } else if (editSGUser.GroupId != student.GroupId) { editSGUser.GroupId = student.GroupId; db.StudentGroups.Update(editSGUser); } db.Users.Update(editUser); db.SaveChanges(); } }
public void initializeTimeTable() { for (var roomsIterator = this.rooms.GetEnumerator(); roomsIterator.MoveNext(); ) { ClassRoom room = roomsIterator.Current; if (room.isLaboratory()) { this.practicalRooms.Add(room); } else { this.theoryRooms.Add(room); } } for (var studentGroupIterator = this.studentGroups.GetEnumerator(); studentGroupIterator.MoveNext(); ) { StudentGroups studentGroup = studentGroupIterator.Current; if (studentGroup.IsPractical()) { this.practicalStudentGroups.Add(studentGroup); } else { this.theoryStudentGroups.Add(studentGroup); } } this.rooms.Clear(); // studentGroups.clear(); setTimeTable(this.practicalStudentGroups, this.practicalRooms, "practical"); setTimeTable(this.theoryStudentGroups, this.theoryRooms, "theory"); this.rooms.AddRange(this.practicalRooms); this.rooms.AddRange(this.theoryRooms); // studentGroups.addAll(practicalStudentGroups); // studentGroups.addAll(theoryStudentGroups); }
public AssessmentViewModel(int numOfStudents, int studentsPerPage, List <Chapter> chapters, PageService _pageService) { this.studentsPerPage = studentsPerPage; this.numOfStudents = numOfStudents; this._pageService = _pageService; _students = new ObservableCollection <Student>(); for (int x = 1; x <= numOfStudents; x++) { _students.Add(new Student { Name = "student " + x }); } Students = new ObservableCollection <StudentAndList>(); for (int s = 0; s < _students.Count; s++) { Students.Add(new StudentAndList(_students[s], chapters[s])); } int i = 0; while (i < _students.Count) { ObservableCollection <StudentAndList> temp = new ObservableCollection <StudentAndList>(Students.ToList().GetRange(i, Math.Min(studentsPerPage, Students.Count - i))); StudentListGroup sg = new StudentListGroup(temp); StudentGroups.Add(sg); i += studentsPerPage; } MistakeItemPressedCommand = new Command <ToolbarItem>((e) => MistakeItemPressedMethod(e)); MessagingCenter.Subscribe <AssessmentPage, Tuple <StudentAndList, Word, string> >(this, "MostRecentView", (sender, arg) => { _selectedStudentAndList = arg.Item1; _selectedWord = arg.Item2; _partOfWord = arg.Item3; TheWord = _partOfWord; }); }
public static void Main(string[] args) { // Linq's Join is equivalent to SQL's Inner Join // Linq's GroupJoin is equivalent to SQL's Outer Join // Left Outer Join and Right Outer Join can be performed by exchanging data source // Cross Join doesn't require common property. It generates cartesian products of the collection var joinQuerySyntax = from dept in Department.GetAllDepartments() join std in Student.GetAllStudents() on dept.ID equals std.DepartmentId select new { Name = std.Name, Department = dept.Name }; //foreach(var std in joinQuerySyntax) //{ // Console.WriteLine(std.Name + " " + std.Department); //} var groupJoinQuerySyntax = from dept in Department.GetAllDepartments() join std in Student.GetAllStudents() on dept.ID equals std.DepartmentId into StudentGroups // List of children. Here it is list of Student select new { Department = dept.Name, StudentGroups = StudentGroups }; // from p in Parent // join c in Child // on p.Id equals c.Id into GROUPJOIN // select new { NewParent = Parent, NewChildren = GROUPJOIN}; // NewChildren is a list of Children. It can be empty if there is no children //Outer Foreach is for all department //foreach (var item in groupJoinQuerySyntax) //{ // Console.WriteLine("Department :" + item.Department); // //Inner Foreach loop for each student of a department // foreach (var student in item.StudentGroups) // { // Console.WriteLine(" StudentID : " + student.Id + " , Name : " + student.Name); // } //} var flattenedQuerySyntax = from dept in Department.GetAllDepartments() join std in Student.GetAllStudents() on dept.ID equals std.DepartmentId into StudentGroups from student in StudentGroups.DefaultIfEmpty() select new { Department = dept, StudentName = student?.Name }; //foreach(var item in flattenedQuerySyntax) //{ //Console.WriteLine("Department - " + item.Department.Name + " . Student - " + item.StudentName); //} var crossJoin = from std in Student.GetAllStudents() from dept in Department.GetAllDepartments() select new { Name = std.Name, Depatment = dept.Name }; Console.WriteLine(crossJoin.LongCount()); // Number of Student * Number of Department }
static void Main(string[] args) { List <Student> students = new List <Student>() { new Student() { Id = 0, Name = "Zakir", GroupId = 1 }, new Student() { Id = 1, Name = "Zahid", GroupId = 2 }, new Student() { Id = 2, Name = "Limon", GroupId = 3 }, new Student() { Id = 3, Name = "Pranto", GroupId = 4 }, new Student() { Id = 4, Name = "Rakib", GroupId = 5 }, new Student() { Id = 5, Name = "Shuvo", GroupId = 6 }, new Student() { Id = 6, Name = "Shovon", GroupId = 7 } }; List <Category> categories = new List <Category>() { new Category() { Id = 0, Group = "Group A", StudentId = 1 }, new Category() { Id = 1, Group = "Group B", StudentId = 2 }, new Category() { Id = 2, Group = "Group C", StudentId = 3 }, new Category() { Id = 3, Group = "Group D", StudentId = 4 } }; var QueryLeftJoin = (from std in students join cat in categories on std.GroupId equals cat.StudentId into StudentGroups from stdgroup in StudentGroups.DefaultIfEmpty() select new { StudentName = std.Name, StudentGroup = stdgroup != null ? stdgroup.Group : "NA" }).ToList(); foreach (var item in QueryLeftJoin) { Console.WriteLine($"Student Name={item.StudentName} Group={item.StudentGroup}"); } }
public void setStudentGroup(StudentGroups studentGroup) { this.studentGroup = studentGroup; }