Exemplo n.º 1
0
        public ObjectResult Put(int id, [FromForm] WebApiEvent apiEvent)
        {
            var updatedEvent = (DatePickerEvent)apiEvent;
            var dbEvent      = _context.tblSeanceCours.Find(id);

            dbEvent.enseignantId = updatedEvent.enseignantId;
            if (updatedEvent.local is null)
            {
                dbEvent.local = "";
            }
            else
            {
                dbEvent.local = updatedEvent.local;
            }


            dbEvent.nomCours  = updatedEvent.nomCours;
            dbEvent.startTime = updatedEvent.startTime;
            dbEvent.endTime   = updatedEvent.endTime;
            _context.SaveChanges();

            return(Ok(new
            {
                action = "updated"
            }));
        }
Exemplo n.º 2
0
        public ActionResult IndexPost()
        {
            var users = GetEnseignant().ToList();

            foreach (IdentityUser e in GetProfSout())
            {
                users.Add(e);
            }
            foreach (IdentityUser personne in users)
            {
                if (HttpContext.Request.Form[personne.Id] == "oui")
                {
                    IEnumerable <string> Roles = (from p in _context.AspNetRoles where p.Name == "ProfDeSoutien" select p.Id).ToList();
                    IEnumerable <IdentityUserRole <string> > User = (from p in _context.AspNetUserRole where p.UserId == personne.Id select p).ToList();
                    User.First().RoleId = Roles.First();
                    _context.SaveChanges();
                }
                else if (HttpContext.Request.Form[personne.Id] == "non")
                {
                    if (personne.Email.Contains("dmin") == false)
                    {
                        IEnumerable <string> Roles             = (from p in _context.AspNetRoles where p.Name == "Enseignant" select p.Id).ToList();
                        List <IdentityUserRole <string> > data = _context.AspNetUserRole.Where(e => e.UserId == personne.Id).Select(e => e).ToList();
                        _context.AspNetUserRole.Where(e => e.UserId == personne.Id).Select(e => e).First().RoleId = Roles.First();
                        _context.SaveChanges();
                    }
                }
            }
            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
        public ObjectResult Post([FromForm] WebApiEvent apiEvent)
        {
            var newEvent = (DatePickerEvent)apiEvent;

            newEvent.enseignantId = User.FindFirst(ClaimTypes.NameIdentifier).Value;
            _context.tblSeanceCours.Add(newEvent);
            _context.SaveChanges();

            return(Ok(new
            {
                tid = newEvent.id,
                action = "inserted"
            }));
        }
Exemplo n.º 4
0
        public IActionResult Supprimer(int id)
        {
            try
            {
                _context.tblQuestion.Remove(_context.tblQuestion.Find(id));
                foreach (Question q in _context.tblQuestion.Where(e => e.position > _context.tblQuestion.Find(id).position))
                {
                    q.position--;
                }

                _context.SaveChanges();
            }
            catch (Exception)
            {
            }
            return(RedirectToAction("index"));
        }
Exemplo n.º 5
0
        public IActionResult RencontrePost(int tRencontreId)
        {
            _context.tblEvaluation.Where(e => e.rencontreId == tRencontreId).First().disponible = true;
            _context.SaveChanges();


            model.Evaluation            = _context.tblEvaluation.Where(e => e.rencontreId == tRencontreId).Select(e => e).ToList().First();
            model.LstQuestion           = (from pQuestion in _context.tblQuestion select pQuestion).ToList();
            model.LstEvaluationQuestion = (from p in _context.tblEvaluationQuestion where p.evaluationId == model.Evaluation.id select p).ToList();
            _context.tblEvaluation.Where(e => e.rencontreId == tRencontreId).Select(e => e).ToList().First().commentaire = HttpContext.Request.Form["commentaire"];
            _context.SaveChanges();

            int cpt = 0;

            foreach (Question tQuestion in model.LstQuestion)
            {
                string questionString = tQuestion.id.ToString();
                _context.tblEvaluationQuestion.Find(model.Evaluation.id, tQuestion.id).resultat = Convert.ToInt32(HttpContext.Request.Form[questionString]);
                _context.SaveChanges();
                if (_context.tblEvaluationQuestion.Find(model.Evaluation.id, tQuestion.id).resultat != null)
                {
                    cpt += (int)_context.tblEvaluationQuestion.Find(model.Evaluation.id, tQuestion.id).resultat;
                }
            }
            _context.tblEvaluation.Find(model.Evaluation.id).resultat = cpt;

            _context.SaveChanges();
            if (User.IsInRole("Etudiant"))
            {
                return(RedirectToAction("Index", "Rencontre"));
            }
            else if (User.IsInRole("Enseignant"))
            {
                return(RedirectToAction("Index", "Rencontre"));
            }
            else if (User.IsInRole("ProfDeSoutien"))
            {
                return(RedirectToAction("Index", "Navigation"));
            }
            else
            {
                return(RedirectToPage("Index", "Navigation"));
            }
        }
Exemplo n.º 6
0
 public IActionResult VerouillerPost()
 {
     _context.tblAdminCommand.Select(e => e).First().rencontreFixed = true;
     _context.SaveChanges();
     return(RedirectToAction("Index"));
 }