// // GET: /GestionDesClasses/Edit/5 public ActionResult EditEtablissement(Guid id) { EtablissementModels model; using (EtablissementRepository repository = new EtablissementRepository()) { IQueryable <Academies> academies = repository.GetAcademies(); IQueryable <Users> users = repository.GetUsers(); Establishments a = repository.GetEtablissementById(id); if (a == null) { return(HttpNotFound()); } model = new EtablissementModels { mode = 0, id = a.Id, name = a.Name, address = a.Address, postCode = a.PostCode, town = a.Town, academieId = a.Academie_Id, userId = a.User_Id, academies = getListAcademies(academies), users = getListUsers(users) }; } return(View("CreateEtablissement", model)); }
public ActionResult CreateEtablissement(EtablissementModels model) { if (ModelState.IsValid) { using (EtablissementRepository repository = new EtablissementRepository()) { Establishments a = new Establishments { Id = Guid.NewGuid(), Name = model.name, Address = model.address, PostCode = model.postCode, Town = model.town, User_Id = model.userId, Academie_Id = model.academieId }; repository.Add(a); repository.Save(); } return(RedirectToAction("ReadEtablissements")); } return(View(model)); }
// GET: /GestionDesClasses/CreateEtablissement public ActionResult CreateEtablissement(Guid?academie, Guid?user) { EtablissementModels model; using (EtablissementRepository repository = new EtablissementRepository()) { IQueryable <Academies> academies = repository.GetAcademies(); IQueryable <Users> users = repository.GetUsers(); model = new EtablissementModels { mode = -1, academies = getListAcademies(academies), users = getListUsers(users), }; if (academie != null) { model.academieId = (Guid)academie; } if (user != null) { model.userId = (Guid)user; } } return(View(model)); }
// GET: /GestionDesClasses/ReadEtablissement/1122 public ActionResult ReadEtablissement(Guid id) { EtablissementModels model; using (EtablissementRepository repository = new EtablissementRepository()) { Establishments a = repository.GetEtablissementById(id); IQueryable <Classrooms> e = repository.GetClassroomById(a.Id); if (a == null) { return(HttpNotFound()); } model = new EtablissementModels { id = a.Id, name = a.Name, address = a.Address, postCode = a.PostCode, town = a.Town, userId = a.User_Id, academieId = a.Academie_Id, userName = a.Users.UserName, academieName = a.Academies.Name, classrooms = getListClasses(e) }; } return(View(model)); }
public ActionResult DeleteEtablissement(EtablissementModels model) { using (EtablissementRepository repository = new EtablissementRepository()) { repository.DeleteById(model.id); repository.Save(); } return(View("Index")); }
public ActionResult SearchEtablissements(String query) { IList <EtablissementModels> models = new List <EtablissementModels>(); using (EtablissementRepository repository = new EtablissementRepository()) { models = repository.GetEtablissementsByQuery(query).Select(x => new EtablissementModels { id = x.Id, name = x.Name, address = x.Address, postCode = x.PostCode, town = x.Town }).ToList(); } return(PartialView("_etablissementsList", models)); }
// GET: /GestionDesClasses/ReadEtablissements public ActionResult ReadEtablissements() { IList <EtablissementModels> models = new List <EtablissementModels>(); using (EtablissementRepository repository = new EtablissementRepository()) { IQueryable <Establishments> a = repository.All(); models = repository.All().Select(x => new EtablissementModels { id = x.Id, name = x.Name, address = x.Address, postCode = x.PostCode, town = x.Town }).ToList(); } return(View(models)); }
public ActionResult EditEtablissement(EtablissementModels model) { using (EtablissementRepository repository = new EtablissementRepository()) { Establishments a = repository.GetEtablissementById(model.id); a.Name = model.name; a.Address = model.address; a.PostCode = model.postCode; a.Town = model.town; a.User_Id = model.userId; a.Academie_Id = model.academieId; if (ModelState.IsValid) { repository.Save(); } return(RedirectToAction("ReadEtablissements")); } }
// GET: /GestionDesClasses/DeleteEtablissement/5 public ActionResult DeleteEtablissement(Guid id) { EtablissementModels model; using (EtablissementRepository repository = new EtablissementRepository()) { Establishments a = repository.GetEtablissementById(id); if (a == null) { return(HttpNotFound()); } model = new EtablissementModels { id = a.Id, name = a.Name, address = a.Address, postCode = a.PostCode, town = a.Town, }; } return(View("DeleteEtablissement", model)); }