Example #1
0
        public ActionResult Update()
        {
            EleveVM elevevm = new EleveVM(EleveRequest.GetEleveById(long.Parse(User.Identity.Name)));

            ViewBag.Classe = new SelectList(ClasseRequest.GetAllClasses(), "id", "libelle", elevevm.Eleve.idClasse);
            return(View(elevevm));
        }
 public ActionResult Add(EleveVM model)
 {
     if (ModelState.IsValid)
     {
         Eleve eleve = new Eleve()
         {
             Absences = model.Absences, ClasseId = model.ClasseId, DateDeNaissance = model.DateDeNaissance, Nom = model.Nom, Notes = model.Notes, Prenom = model.Prenom
         };
         Manager.Instance.AjouterEleve(eleve);
         return(RedirectToAction("EleveList", "Eleve"));
     }
     return(View());
 }
        // GET: Eleves/Details/5
        public ActionResult Details(int id)
        {
            Eleve             eleve       = _bm.GetEleveById(id);
            List <Note>       notes       = _bm.GetNotesByEleve(eleve.EleveId);
            List <NoteVM>     noteVMS     = new List <NoteVM>();
            List <Absence>    abscences   = _bm.GetAbscences(eleve.EleveId);
            List <AbscenceVM> abscenceVMS = new List <AbscenceVM>();

            if (eleve == null)
            {
                return(HttpNotFound());
            }


            if (notes != null)
            {
                foreach (var note in notes)
                {
                    noteVMS.Add(new NoteVM
                    {
                        NoteObtenue  = note.NoteObtenue,
                        Appreciation = note.Appreciation,
                        DateNote     = note.DateNote
                    });
                }
            }
            if (abscences != null)
            {
                foreach (var abscence in abscences)
                {
                    abscenceVMS.Add(new AbscenceVM
                    {
                        DateAbsence = abscence.DateAbsence,
                        Motif       = abscence.Motif
                    });
                }
            }

            EleveVM eleveVM = new EleveVM
            {
                Nom           = eleve.Nom,
                Prenom        = eleve.Prenom,
                DateNaissance = eleve.DateNaissance,
                Notes         = noteVMS,
                Absences      = abscenceVMS
            };

            return(View(eleveVM));
        }