public ActionResult DeleteTuteur(Guid id)
        {
            TuteurModels model;

            using (TuteurRepository repository = new TuteurRepository())
            {
                Tutors x = repository.GetTutorById(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,
                    // eleves =
                };
            }


            return(View("DeleteTuteur", 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"));
 }
        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"));
            }
        }
        public ActionResult SearchTuteurs(String query)
        {
            IList <TuteurModels> models = new List <TuteurModels>();

            using (TuteurRepository repository = new TuteurRepository())
            {
                models = repository.GetTuteursByQuery(query).Select(x => 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,
                    // eleves =
                }).ToList();
            }
            return(PartialView("_tuteursList", models));
        }
        // GET: /Eleves/ReadTuteurs
        public ActionResult ReadTuteurs()
        {
            IList <TuteurModels> models = new List <TuteurModels>();

            using (TuteurRepository repository = new TuteurRepository())
            {
                IQueryable <Tutors> a = repository.All();

                models = repository.All().Select(x => 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,
                }).ToList();
            }
            return(View(models));
        }