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 IHttpActionResult Edit(CadetListItem cadetModel)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            Cadet cadet = service.CadetEdit(cadetModel);
            service.Save();

            return Json(new CadetListItem(cadet));
        }
        public Cadet CadetEdit(CadetListItem cadetModel)
        {
            Cadet cadet = CadetGetByID(cadetModel.CadetID);
            Section section = SectionGetByID(cadetModel.Section.SectionID);
            Grade grade = GradeGetByID(cadetModel.Grade.GradeID);

            cadet.NbBilletsDistribue = cadetModel.NbBilletsDistribue;
            cadet.NbBilletsVendu = cadetModel.NbBilletsVendu;
            cadet.Nom = cadetModel.Nom;
            cadet.Prenom = cadetModel.Prenom;

            if(cadet.Section != null)
                cadet.Section.Cadets.Remove(cadet);
            if(cadet.Grade != null)
                cadet.Grade.Cadets.Remove(cadet);

            cadet.Grade = grade;
            cadet.Section = section;

            if (section != null)
                section.Cadets.Add(cadet);
            if (grade != null)
                grade.Cadets.Add(cadet);

            return cadet;
        }