public void CancelChanges() { if (IsNew) { Code = 0; Title = null; Teacher = null; DaysOfWeek = 0; StartDate = new DateTime(0001, 01, 01); FinishDate = new DateTime(0001, 01, 01); RaisePropertyChanged(nameof(Course)); } else { var change = (from c in App.Model.ChangeTracker.Entries <Course>() where c.Entity == Course select c).FirstOrDefault(); if (change != null) { change.Reload(); RaisePropertyChanged(nameof(Title)); RaisePropertyChanged(nameof(Teacher)); RaisePropertyChanged(nameof(DaysOfWeek)); RaisePropertyChanged(nameof(StartDate)); RaisePropertyChanged(nameof(FinishDate)); RaisePropertyChanged(nameof(StartTime)); RaisePropertyChanged(nameof(EndTime)); Stud.RefreshFromModel(Course.Student); Students.RefreshFromModel(Course.Student); NonStudents.RefreshFromModel(AllStudents.Except(Students)); } } }
public void RegisterStudent() { Console.WriteLine("Registering of a new student"); Console.Write("Type his/her name : "); string name = Console.ReadLine(); Console.Write("Type his/her adress : "); string adress = Console.ReadLine(); Console.Write("Type his/her phone number : "); string phoneNumber = Console.ReadLine(); Console.Write("Type his/her email : "); string email = Console.ReadLine(); Console.Write("Type his/her password : "******"Type the name of his/her branch : "); string branchName = Console.ReadLine(); Console.Write("Type the number of payments : "); int nbrPayment = Convert.ToInt32(Console.ReadLine()); int index = Branches.IndexOfKey(branchName); Branche branche = Branches.ElementAt(index).Value; Student student = new Student(name, adress, phoneNumber, email, password, branche, nbrPayment, 0, 0, 0, AllCourses[index], AllCourses[index].Count); AllStudents.Add(student); }
/// <summary> /// Displays student by searched Id. /// </summary> /// <param name="id"></param> public void DisplayStudentById(int id) { AllUsers.Clear(); foreach (Student p in AllStudents.ToList()) { if (p.StudentId == id) { AllUsers.Add(p); } } }
/// <summary> /// We get the picked student and sends it to be deleted from DB /// </summary> /// <param name="student"></param> public void DeleteStudent(Student student) { ApiHelper.Instance.DeleteStudent(student.StudentId); foreach (Student s in AllStudents.ToList()) { if (s.StudentId == student.StudentId) { AllStudents.Remove(s); AllUsers.Remove(s); } } }
public List <Student> Display(List <DataStudent> concat) { List <Student> finalList = new List <Student>(); foreach (DataStudent s in concat) { finalList.Add((Student)users[s.username]); } AllStudents.Add(Student_to_match); return(finalList); }
private List <ReportStudent> GetPreparedStudent(IEnumerable <JHStudentRecord> students) { List <ReportStudent> result = new List <ReportStudent>(); foreach (JHStudentRecord each in students) { if (AllStudents.ContainsKey(each.ID)) { result.Add(AllStudents[each.ID]); } } return(result); }
public List <Student> MatchStudents() { foreach (DataStudent student in AllStudents) { student.totalDistance += CalculateDistance(Student_to_match, student); } AllStudents.Sort((x, y) => x.totalDistance.CompareTo(y.totalDistance)); List <DataStudent> concat = new List <DataStudent>(); for (int i = 0; i < 5; i++) { concat.Add(AllStudents[i]); } return(Display(concat)); }
public void RemoveStudent() { Console.WriteLine("Deleting a student"); Console.Write("Type his/her name : "); string name = Console.ReadLine(); foreach (Student student in AllStudents) { if (student.Name == name) { AllStudents.Remove(student); Console.WriteLine($"{student.Name} has been removed"); break; } } }
private void RemoveRecord() { if (MessageBox.Show("Are sure to delete this student ? ", "Confirm", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No) { return; } SchoolObjContext context = new SchoolObjContext(); dynamic item = CurrentItem; EntityDatabase.DomainClasses.Student SelectedStudent = CurrentItem.Student; EntityDatabase.DomainClasses.Student obj = context.Students.Where(s => s.StudentId == SelectedStudent.StudentId).FirstOrDefault(); if (obj == null) { return; } context.Students.Remove(obj); context.SaveChanges(); AllStudents.Remove(CurrentItem); }
public IActionResult GetAllStudents() { List <Project> projects = _projectService.GetAll(); List <ProjectViewModel> projectModel = new List <ProjectViewModel>(); foreach (var project in projects) { projectModel.Add(new ProjectViewModel() { Id = project.Id, Title = project.Title, EstimatedTime = project.EstimatedTime, TimeSpent = project.TimeSpent, StudentId = project.StudentId }); } List <Student> students = _studentService.GetAll(); List <StudentViewModel> all = new List <StudentViewModel>(); foreach (var student in students) { all.Add(new StudentViewModel() { Id = student.Id, FirstName = student.FirstName, LastName = student.LastName, Age = student.Age, Academy = student.Academy, Projects = projectModel }); } AllStudents model = new AllStudents() { All_Students = all }; return(View(model)); }
public Student() { AllStudents.Add(this); }
private void button2_Click(object sender, EventArgs e) { List <Tuple <string, string, string, string> > list = new List <Tuple <string, string, string, string> >(); for (int i = 0; i < studAll.Count; i++) { if (studAll[i].Item3.Contains("*Тест не пройден*")) { continue; } string name = studAll[i].Item2; string[] roles = studAll[i].Item3.Split(new char[] { ',' }); list.Add(new Tuple <string, string, string, string>(name, roles[0], roles[1], roles[2])); } if (list.Count < 3) { while (NewTeam.Items.Count != 0) { NewTeam.SelectedIndex = 0; ToLeft_Click(sender, e); } for (int i = 0; i < 3 && i < AllStudents.Items.Count; i++) { AllStudents.SelectedIndex = 0; ToRight_Click(sender, e); if (i == 0) { Leader.SelectedIndex = 0; } } buildRecommend(); return; } List <Tuple <string, string, string, string> > first = _getFirst(list); if (first.Count == 0) { while (NewTeam.Items.Count != 0) { NewTeam.SelectedIndex = 0; ToLeft_Click(sender, e); } for (int i = 0; i < 3 && i < AllStudents.Items.Count; i++) { AllStudents.SelectedIndex = 0; ToRight_Click(sender, e); if (i == 0) { Leader.SelectedIndex = 0; } } buildRecommend(); return; } bool isFormed = false; List <string> names = new List <string>(); for (int i = 0; i < first.Count; i++) { if (isFormed) { break; } List <Tuple <string, string, string, string> > second = _getSecond(list, first[i]); for (int j = 0; j < second.Count; j++) { if (isFormed) { break; } List <Tuple <string, string, string, string> > third = _getSecond(list, second[j]); for (int k = 0; k < third.Count; k++) { if (first[i].Item2 == third[k].Item2 && first[i].Item3 == third[k].Item3 && first[i].Item4 == third[k].Item4) { continue; } names.Add(first[i].Item1); names.Add(second[j].Item1); names.Add(third[k].Item1); isFormed = true; break; } } } while (NewTeam.Items.Count != 0) { NewTeam.SelectedIndex = 0; ToLeft_Click(sender, e); } if (names.Count == 3) { for (int i = 0; i < names.Count; i++) { int indx = AllStudents.FindString(names[i]); AllStudents.SelectedIndex = indx; ToRight_Click(sender, e); if (i == 0) { Leader.SelectedIndex = 0; } } } buildRecommend(); }
public MainViewModel(INavigationService navigation = null) { _navSvc = navigation; Students = new ObservableCollection <Student>(AllStudents.GetAllStudents()); Debug.WriteLine("Exec view"); }
/// <summary> /// 获取正在参与学习的学生 /// </summary> /// <returns></returns> public ApiModels.Student GetStudyStudent(long studentId) { return(AllStudents.Where(m => m.id == studentId).FirstOrDefault()); }
/// <summary> /// 获取正在参与学习的学生列表 /// </summary> /// <returns></returns> public List <ApiModels.Student> GetStudyStudents() { return(AllStudents.Where(m => StudentIds.Any(c => m.id == c)).ToList()); }
public MainPageViewModel(INavigationService navigationService) { Students = new ObservableCollection <Student>(AllStudents.GetAllStudents()); _navigationService = navigationService; }