Ejemplo n.º 1
0
 public override string ToString()
 {
     return(StudentId + "," +
            Name + "," +
            Surname + "," +
            DateUtilities.DateTimeToStringES(DateOfBirth) +
            "\n");
 }
Ejemplo n.º 2
0
        private XElement CreateStudentElement(Student student)
        {
            XElement studentElement = new XElement("student", "");

            studentElement.Add(
                new XElement("id", student.StudentId),
                new XElement("name", student.Name),
                new XElement("surname", student.Surname),
                new XElement("dateOfBirth", DateUtilities.DateTimeToStringES(student.DateOfBirth)));

            return(studentElement);
        }
Ejemplo n.º 3
0
        private void BtnFind(IAbstractStudentDAO dao)
        {
            int     studentId    = Int32.Parse(txtStudentId.Text);
            Student foundStudent = dao.FindById(studentId);

            if (foundStudent != null)
            {
                txtStudentId.Text   = foundStudent.StudentId.ToString();
                txtName.Text        = foundStudent.Name;
                txtSurname.Text     = foundStudent.Surname;
                txtDateOfBirth.Text = DateUtilities.DateTimeToStringES(foundStudent.DateOfBirth);
            }
        }
Ejemplo n.º 4
0
        public Student Update(int id, Student updatedStudent)
        {
            if (!File.Exists(FilePath))
            {
                throw new Exception("No file found " + FilePath);
            }
            xDocument = XDocument.Load(FilePath);

            var studentToUpdate = from student in xDocument.Elements("students").Elements()
                                  where student.Element("id").Value.Equals(id.ToString())
                                  select student;

            GetFirstElement(studentToUpdate).Element("name").Value        = updatedStudent.Name;
            GetFirstElement(studentToUpdate).Element("surname").Value     = updatedStudent.Surname;
            GetFirstElement(studentToUpdate).Element("dateOfBirth").Value = DateUtilities.DateTimeToStringES(updatedStudent.DateOfBirth);
            xDocument.Save(FilePath);
            return(updatedStudent);
        }