Пример #1
0
        //
        // 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));
        }
Пример #2
0
        // 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));
        }
Пример #3
0
        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"));
            }
        }
Пример #4
0
        // 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));
        }