/// <summary> /// Запросить список студентов у сервера. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void srudbtn_Click(object sender, EventArgs e) { GetStudents?.Invoke(this, e); this.booksbtn.Enabled = false; this.studbtn.Enabled = false; this.debtbtn.Enabled = false; }
/** * <summary>This method removes a student at a particular index position, inside the AcademicYear object.</summary> * * <example> * <code>AcademicYear yr = new AcademicYear(10); * yr.AddStudentToYear(new Student("5003", "Chris", "Archer", 10, "Green")); * yr.AddStudentToYear(new Student("4500", "Hayden", "Collins", 10, "Red")); * yr.AddStudentToYear(new Student("5210", "James", "Holder", 10, "Blue")); * yr.RemoveStudentFromYear(1);</code> * The student at index position 1 (Hayden Collins) will be removed.</example> */ public void RemoveStudentFromYear(int i) { if (0 <= i && i < GetStudents.Count) { GetStudents.RemoveAt(i); } }
// Methods. /** * <summary>This method stores a valid Student object into the AcademicYear object.</summary> * * <param name="s">Student object to be added to the year.</param> * * <example> * <code>AcademicYear yr = new AcademicYear(12); * yr.AddStudentToYear(new Student("8126", "Edward", "Willis", 12, "Red"));</code> * A new student has been added to 'yr'.</example> */ public void AddStudentToYear(Student s) { if (s != null && s.GetYear == GetYearNo) { // Throws an exception if the student already exists within the AcademicYear object. //GetStudents.ForEach(student => { if (student.GetStudentID == s.GetStudentID) { throw new ArgumentException("Student already exists!"); } }); GetStudents.Add(s); } }
public static List <Student> GetStudentsInList(List <Student> s, GetStudents del, object o = null) { List <Student> result = new List <Student>(); foreach (var student in s) { if (del(student, o)) { result.Add(student); } } return(result); }
/** * <summary>This method removes removes any duplicate students inside the AcademicYear object.</summary> * * <example> * <code>AcademicYear yr = new AcademicYear(9); * yr.AddStudentToYear(new Student("2950", "Wendy", "Foakes", 9, "Mauve")); * yr.AddStudentToYear(new Student("2950", "Wendy", "Foakes", 9, "Mauve")); * yr.AddStudentToYear(new Student("4125", "Stewart", "Richards", 9, "Teal")); * yr.RemoveStudentFromYear(1);</code> * The second occurence of "Wendy Foakes" will be removed as it already exists once.</example> */ public void RemoveDuplicateStudents() { for (int i = 0; i < GetStudents.Count; i++) { for (int j = i + 1; j < GetStudents.Count; j++) { if (GetStudent(i).GetStudentID == GetStudent(j).GetStudentID) { RemoveStudentFromYear(j); j--; } } } GetStudents.Sort(); // Sorts the subjects inside GetStudents into a natural order. }
/** * <summary>This method retrieves the Student object matched by the 'ID' string.</summary> * * <param name="ID">The ID string to be used to get the matching Student object.</param> * * <example> * <code>AcademicYear yr = new AcademicYear(7); * yr.AddStudentToYear(new Student("0796", "Christine", "Lively", 7, "Indigo")); * yr.AddStudentToYear(new Student("1472", "Jessica", "Rhodes", 7, "Magenta")); * yr.AddStudentToYear(new Student("1140", "Frank", "London", 7, "Cyan")); * yr.GetStudentByID("0796");</code> * The student with the ID value "0796" (Christine Lively) will be returned.</example> * * <returns>Returns the student with the matching ID specifed by the 'ID' parameter.</returns> */ public Student GetStudentById(string ID) { Student student = null; if (!string.IsNullOrWhiteSpace(ID)) { GetStudents.ForEach(_ => { if (_.GetStudentID == ID) { student = _; } }); } if (student == null) { // Throws an exception if student is still equal to null. throw new ArgumentException("No student with that ID number exists!"); } return(student); }
/// <summary> /// Get a List of all Students /// </summary> /// <returns>The <see cref="List{Student}"/> of all returned Students.</returns> public async Task <List <Student> > GetStudents() { //Get the JSON GetStudents students = new GetStudents(); //Send and receive JSON from WebUntis string requestJson = JsonConvert.SerializeObject(students); string responseJson = await SendJsonAndWait(requestJson, _url, SessionId); //Parse JSON to Class StudentsResult result = JsonConvert.DeserializeObject <StudentsResult>(responseJson); string errorMsg = wus.LastError.Message; if (!SuppressErrors && errorMsg != null) { Logger.Append(Logger.LogLevel.Error, errorMsg); throw new WebUntisException(errorMsg); } return(result.result != null ? new List <Student>(result.result) : new List <Student>()); }
private void ChangeExem_Click(object sender, EventArgs e) { GetStudents students = new GetStudents(); if (Students.Text.Length != 0) { int subject = Subject.SelectedIndex; string studentSurname = Students.Text; string mark = Mark.Text; var student = students.getConcrete(studentSurname)[0]; string newMark = ""; for (int markIndex = 0; markIndex < 5; markIndex++) { if (markIndex == subject) { newMark += mark; } else { newMark += student.Exems[markIndex]; } } Student updated = new Student(student.ID, student.Group, student.Surname, newMark, student.Scores); UpdateStudentsTable update = new UpdateStudentsTable(); List <Student> students1 = new List <Student> { updated }; update.Update(students1); main.UpdateData(); UpdateViews(); } }
public async Task <object> Get(GetStudents request) { Expression <Func <Student, bool> > filter = x => (request.FirstName == null || x.FirstName.Contains(request.FirstName)) && (request.LastName == null || x.LastName.Contains(request.LastName)) && (request.StudentCode == null || x.StudentCode.Contains(request.StudentCode)) && (request.DateOfBirth == null || (x.DateOfBirth.HasValue && x.DateOfBirth.Value.ToString("yyyy-MM-dd").Equals(request.DateOfBirth))) && (request.ClassId == null || x.ClassId == request.ClassId); var studentEntities = await _studentService.GetAll(filter : filter, includeProperties : "Class"); var dtos = studentEntities.ToList().ConvertAll(x => { var dto = x.ConvertTo <StudentDto>(); dto.ClassName = x.Class.Name; return(dto); }); return(new { Success = true, StatusCode = (int)HttpStatusCode.OK, Results = dtos, ItemCount = dtos.Count }); }
public async Task <IActionResult> Get([FromRoute] GetStudents query) => Select(await Dispatcher.QueryAsync(query));
public async Task <IEnumerable <StudentDto> > Handle(GetStudents request, CancellationToken cancellationToken) { var students = await _context.Student.ToListAsync(cancellationToken : cancellationToken); return(students.AsDto()); }