Beispiel #1
0
        //
        // GET: /GestionDesClasses/EditClasse/5

        public ActionResult EditClasse(Guid id)
        {
            ClasseModels model;

            using (ClasseRepository repository = new ClasseRepository())
            {
                IQueryable <Years>          years          = repository.GetYears();
                IQueryable <Users>          users          = repository.GetUsers();
                IQueryable <Establishments> etablissements = repository.GetEtablissements();
                Classrooms c = repository.GetClasseById(id);
                if (c == null)
                {
                    return(HttpNotFound());
                }
                model = new ClasseModels
                {
                    mode            = 0,
                    id              = c.Id,
                    title           = c.Title,
                    userId          = c.User_Id,
                    yearId          = c.Year_Id,
                    etablissementId = c.Establishment_Id,
                    users           = getListUsers(users),
                    years           = getListYears(years),
                    etablissements  = getListEtablissements(etablissements)
                };
            }
            return(View("CreateClasse", model));
        }
Beispiel #2
0
        // GET: /GestionDesClasses/ReadClasse/1122
        public ActionResult ReadClasse(Guid id)
        {
            ClasseModels model;

            using (ClasseRepository repository = new ClasseRepository())
            {
                Classrooms c = repository.GetClasseById(id);
                //IQueryable<Users> l = repository.GetUserById(id);
                IQueryable <Pupils>      l = repository.GetPupilsById(id);
                IQueryable <Evaluations> e = repository.GetEvaluations(c.Id);
                if (c == null)
                {
                    return(HttpNotFound());
                }
                model = new ClasseModels
                {
                    id                = c.Id,
                    title             = c.Title,
                    userId            = c.User_Id,
                    yearId            = c.Year_Id,
                    etablissementId   = c.Establishment_Id,
                    userName          = c.Users.UserName,
                    yearName          = c.Years.Year,
                    etablissementName = c.Establishments.Name,
                    pupils            = getListEleves(l),
                    evaluations       = getListEvaluations(e)
                };
            }
            return(View(model));
        }
Beispiel #3
0
        public ActionResult EditClasse(ClasseModels model)
        {
            using (ClasseRepository repository = new ClasseRepository())
            {
                Classrooms a = repository.GetClasseById(model.id);

                a.Title            = model.title;
                a.User_Id          = model.userId;
                a.Year_Id          = model.yearId;
                a.Establishment_Id = model.etablissementId;

                if (ModelState.IsValid)
                {
                    repository.Save();
                }
                return(RedirectToAction("ReadClasses"));
            }
        }
Beispiel #4
0
        // GET: /GestionDesClasses/DeleteClasse/5

        public ActionResult DeleteClasse(Guid id)
        {
            ClasseModels model;

            using (ClasseRepository repository = new ClasseRepository())
            {
                Classrooms c = repository.GetClasseById(id);
                if (c == null)
                {
                    return(HttpNotFound());
                }
                model = new ClasseModels
                {
                    id              = c.Id,
                    title           = c.Title,
                    userId          = c.User_Id,
                    yearId          = c.Year_Id,
                    etablissementId = c.Establishment_Id,
                };
            }


            return(View("DeleteClasse", model));
        }