public Cadet CadetAdd(CadetListItem cadetModel) { Cadet cadet = new Cadet(); Section section = null; Grade grade = null; if (cadetModel.Section != null) { section = SectionGetByID(cadetModel.Section.SectionID); section.Cadets.Add(cadet); } if (cadetModel.Grade != null) { grade = GradeGetByID(cadetModel.Grade.GradeID); grade.Cadets.Add(cadet); } cadet.Grade = grade; cadet.NbBilletsDistribue = cadetModel.NbBilletsDistribue; cadet.NbBilletsVendu = cadetModel.NbBilletsVendu; cadet.Nom = cadetModel.Nom; cadet.Prenom = cadetModel.Prenom; cadet.Section = section; cadet.CadetID = data.GetNextCadetID(); data.Cadets.Add(cadet); return cadet; }
public CadetListItem(Cadet cadet) { CadetID = cadet.CadetID; Prenom = cadet.Prenom; Nom = cadet.Nom; NbBilletsDistribue = cadet.NbBilletsDistribue; NbBilletsVendu = cadet.NbBilletsVendu; if(cadet.Grade == null) { Grade = new GradeListItem() { GradeID = -1 }; } else { Grade = new GradeListItem(cadet.Grade); } if (cadet.Section == null) { Section = new SectionListItem() { SectionID = -1 }; } else { Section = new SectionListItem(cadet.Section); } }