public void AddPupil(Pupil p)
 {
     PupilGroups.Add(new PupilGroup
     {
         Pupil = p,
         Group = this
     });
 }
Beispiel #2
0
 public void AddPupil(Pupil p)
 {
     Console.WriteLine(p);
     PupilGroups.Add(new PupilGroup
     {
         Pupil = p,
         Group = this
     });
 }
Beispiel #3
0
        public void UpdatePupil(Pupil pupil)
        {
            PupilGroup oldPupil = null;

            if (pupil.PupilId != 0)
            {
                oldPupil = PupilGroups.SingleOrDefault(p => p.PupilId == pupil.PupilId);
                oldPupil.Pupil.FirstName = pupil.FirstName;
                oldPupil.Pupil.Surname   = pupil.Surname;
            }
            else
            {
                PupilGroups.Add(new PupilGroup()
                {
                    Group = this, GroupId = this.GroupId, Pupil = pupil
                });
            }
        }
Beispiel #4
0
        public void UpdatePupilGroup(ICollection <PupilDTO> pupils, long schoolId)
        {
            foreach (var pupilGroup in PupilGroups)
            {
                var pupilMatch = pupils.FirstOrDefault(p => p.PupilId == pupilGroup.PupilId);
                // when there is no pupilMatch between the given collection and the db collection, the user deleted the pupil
                if (pupilMatch == null)
                {
                    PupilGroups.Remove(pupilGroup);
                }
            }

            //when there are pupils with ID 0 in the given list, the pupils in the group are new
            pupils.ToList().FindAll(np => np.PupilId == 0).ForEach(p =>
            {
                AddPupil(new Pupil(p, schoolId));
            });
        }