Exemplo n.º 1
0
        /// <summary>
        /// Modifie ou crée une note
        /// </summary>
        /// <param name="vm">Objet ViewModel <see cref="NoteViewModel"/></param>
        /// <returns></returns>
        public ActionResult EditNote(NoteViewModel vm)
        {
            if (!ModelState.IsValid)
            {
                return(View("EditNote", vm));
            }

            NoteAdapter  noteAdapter  = new NoteAdapter();
            EleveAdapter eleveAdapter = new EleveAdapter();

            if (vm.NoteId == 0) //Création
            {
                Note note = new Note();
                noteAdapter.ConvertToEntity(note, vm);
                Manager.Instance.AddNote(note);
            }
            else //Modification
            {
                Note note = Manager.Instance.GetNoteById(vm.NoteId);
                noteAdapter.ConvertToEntity(note, vm);
                Manager.Instance.EditNote(note);
            }

            Eleve          eleve   = Manager.Instance.GetEleveById(vm.EleveId);
            EleveViewModel eleveVM = eleveAdapter.ConvertToViewModel(eleve);

            return(RedirectToAction("DetailEleve", "Eleve", new { eleveId = vm.EleveId }));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Modifie ou crée une absence
        /// </summary>
        /// <param name="vm">Objet ViewModel <see cref="AbsenceViewModel"/></param>
        /// <returns></returns>
        public ActionResult EditAbsence(AbsenceViewModel vm)
        {
            if (!ModelState.IsValid)
            {
                return(View("EditAbsence", vm));
            }

            AbsenceAdapter absenceAdapter = new AbsenceAdapter();
            EleveAdapter   eleveAdapter   = new EleveAdapter();

            if (vm.AbsenceId == 0) //Création
            {
                Absence absence = new Absence();
                absenceAdapter.ConvertToEntity(absence, vm);
                Manager.Instance.AddAbsence(absence);
            }
            else //Modification
            {
                Absence absence = Manager.Instance.GetAbsenceById(vm.AbsenceId);
                absenceAdapter.ConvertToEntity(absence, vm);
                Manager.Instance.EditAbsence(absence);
            }

            Eleve          eleve   = Manager.Instance.GetEleveById(vm.EleveId);
            EleveViewModel eleveVM = eleveAdapter.ConvertToViewModel(eleve);

            return(RedirectToAction("DetailEleve", "Eleve", new { eleveId = vm.EleveId }));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Affiche la vue de détail d'un élève
        /// </summary>
        /// <param name="eleveId"></param>
        /// <returns></returns>
        public ActionResult DetailEleve(int eleveId)
        {
            Eleve          eleve        = Manager.Instance.GetEleveById(eleveId);
            EleveAdapter   eleveAdapter = new EleveAdapter();
            EleveViewModel vm           = eleveAdapter.ConvertToViewModel(eleve);

            return(View("DetailEleve", vm));
        }