Esempio n. 1
0
        private void AddUpdateNextOfKin(Student student)
        {
            NextOfKinData nextOfKinData = new NextOfKinData(dbc);

            foreach (NextOfKin nextOfKin in student.NextOfKin)
            {
                if (nextOfKin.PersonId == 0)
                {
                    nextOfKinData.Add(nextOfKin, student.PersonId);
                }
                else
                {
                    bool personExists = nextOfKinData.PersonExists(nextOfKin.PersonId, student.PersonId);
                    if (!personExists)
                    {
                        nextOfKinData.Allocate(nextOfKin, student.PersonId);
                    }
                    else
                    {
                        nextOfKinData.Update(nextOfKin); // update relationship
                    }
                }
            }

            foreach (object obj in student.RemovedObjects)
            {
                if (obj is NextOfKin)
                {
                    nextOfKinData.Remove((NextOfKin)obj, student.PersonId);
                }
            }
        }
Esempio n. 2
0
        public StudentNextOfKinAddEdit(Student student, DBCommand dbc) : base(student, dbc)
        {
            _database = new NextOfKinData(_dbc);
            foreach (NextOfKin nextOfKin in student.NextOfKin)
            {
                if (nextOfKin.PersonId == 0)
                {
                    _database.Add(nextOfKin, student.PersonId);
                }
                else
                {
                    bool personExists = _database.PersonExists(nextOfKin.PersonId, student.PersonId);
                    if (!personExists)
                    {
                        _database.Allocate(nextOfKin, student.PersonId);
                    }
                    else
                    {
                        _database.Update(nextOfKin); // update relationship
                    }
                }
            }

            foreach (object obj in student.RemovedObjects)
            {
                if (obj is NextOfKin)
                {
                    _database.Remove((NextOfKin)obj, student.PersonId);
                }
            }
        }