public ActionResult EditTuteur(Guid id)
        {
            TuteurModels model;

            using (TuteurRepository repository = new TuteurRepository())
            {
                Tutors x = repository.GetTutorById(id);
                if (x == null)
                {
                    return(HttpNotFound());
                }
                model = new TuteurModels
                {
                    mode      = 0,
                    id        = x.Id,
                    firstName = x.FirstName,
                    lastName  = x.LastName,
                    mail      = x.Mail,
                    postCode  = x.PostCode,
                    comment   = x.Comment,
                    town      = x.Town,
                    tel       = x.Tel,
                    address   = x.Address,
                    // eleves =
                };
            }
            return(View("CreateTuteur", model));
        }
        public ActionResult CreateTuteur(TuteurModels model)
        {
            if (ModelState.IsValid)
            {
                using (TuteurRepository repository = new TuteurRepository())
                {
                    Tutors a = new Tutors
                    {
                        Id        = Guid.NewGuid(),
                        FirstName = model.firstName,
                        LastName  = model.lastName,
                        Mail      = model.mail,
                        PostCode  = model.postCode,
                        Comment   = model.comment,
                        Town      = model.town,
                        Tel       = model.tel,
                        Address   = model.address,
                        // eleves =
                    };

                    repository.Add(a);
                    repository.Save();
                }
                return(RedirectToAction("ReadTuteurs"));
            }
            return(View(model));
        }
        public ActionResult ReadTuteur(Guid id)
        {
            TuteurModels model;

            using (TuteurRepository repository = new TuteurRepository())
            {
                Tutors x = repository.GetTutorById(id);
                IQueryable <Pupils> l = repository.GetPupilsById(id);
                if (x == null)
                {
                    return(HttpNotFound());
                }
                model = new TuteurModels
                {
                    id        = x.Id,
                    firstName = x.FirstName,
                    lastName  = x.LastName,
                    mail      = x.Mail,
                    postCode  = x.PostCode,
                    comment   = x.Comment,
                    town      = x.Town,
                    tel       = x.Tel,
                    address   = x.Address,
                    pupils    = getListEleves(l)
                };
            }
            return(View(model));
        }
 public ActionResult DeleteTuteur(TuteurModels model)
 {
     using (TuteurRepository repository = new TuteurRepository())
     {
         repository.DeleteById(model.id);
         repository.Save();
     }
     return(View("Index"));
 }
        // GET: /Eleves/CreateTuteur
        public ActionResult CreateTuteur()
        {
            TuteurModels model = new TuteurModels()
            {
                mode = -1
            };

            return(View(model));
        }
        private List <TuteurModels> getListTuteurs(IQueryable <Tutors> tuteurs)
        {
            List <TuteurModels> ac = new List <TuteurModels>();

            foreach (var aca in tuteurs)
            {
                TuteurModels x = new TuteurModels
                {
                    id        = aca.Id,
                    firstName = aca.FirstName,
                    lastName  = aca.LastName,
                    mail      = aca.Mail,
                    postCode  = aca.PostCode,
                    comment   = aca.Comment,
                    town      = aca.Town,
                    tel       = aca.Tel,
                    address   = aca.Address,
                };
                ac.Add(x);
            }
            return(ac);
        }
        public ActionResult EditTuteur(TuteurModels model)
        {
            using (TuteurRepository repository = new TuteurRepository())
            {
                Tutors x = repository.GetTutorById(model.id);
                x.FirstName = model.firstName;
                x.LastName  = model.lastName;
                x.Mail      = model.mail;
                x.PostCode  = model.postCode;
                x.Comment   = model.comment;
                x.Town      = model.town;
                x.Tel       = model.tel;
                x.Address   = model.address;
                // eleves =

                if (ModelState.IsValid)
                {
                    repository.Save();
                }
                return(RedirectToAction("ReadTuteurs"));
            }
        }