Exemplo n.º 1
0
        public ActionResult MesReservations()
        {
            //Add logic to verify the view of enseignant..
            System.Diagnostics.Debug.WriteLine(User.Identity.Name);

            ReservationModels reservationModel = new ReservationModels();

            int MY_ID_ENS = reservationModel.getIdEnseignant();

            var query = from res in db.RESERVATIONs
                        where res.ENSEIGNEMENT.ENSEIGNANT.ID_ENSEIGNANT == MY_ID_ENS
                        select res;

            var liste_va = from r in query
                           where r.STATUS == 1
                           select r;
            reservationModel.reservations_valides = liste_va.ToList<RESERVATION>();

            var liste_ea = from r in query
                           where r.STATUS == 0
                           select r;
            reservationModel.reservations_enattentes = liste_ea.ToList<RESERVATION>();

            var liste_rf = from r in query
                           where r.STATUS == 2
                           select r;
            reservationModel.reservations_refuses = liste_rf.ToList<RESERVATION>();

            return View(reservationModel);
        }
Exemplo n.º 2
0
        /***AJOUTER/SOUMETTRE UNE RESERVATION***/
        public ActionResult Ajouter()
        {
            ViewBag.liste_salles = new SelectList(db.SALLEs, "ID_SALLE", "NUMERO_SALLE");//"ID_XX" in selectlist is a must coloum in db.XX
            ViewBag.liste_creneaux = new SelectList(db.CRENAUXes, "ID_CRENEAU", "HEURE_DEBUT_AND_HEURE_FIN");

            ReservationModels reservationModel=new ReservationModels();
            int ID_ENSEIGANT_ACTUEL = reservationModel.getIdEnseignant();

            var query = from ensm in db.ENSEIGNEMENTs
                                where ensm.ENSEIGNANT.ID_ENSEIGNANT== ID_ENSEIGANT_ACTUEL
                                select ensm;

            List<ENSEIGNEMENT> liste_ensm = query.ToList<ENSEIGNEMENT>();

            ViewBag.liste_enseignements = new SelectList(liste_ensm, "ID_ENSEIGNEMENT", "DESCRIPTION_ENSEIGNEMENT");
            return View();
        }
Exemplo n.º 3
0
        public ActionResult Index(int id =0)
        {
            //
            bool ensSelectionEstNul = true;
            ENSEIGNANT enseignant = new ENSEIGNANT();
            ReservationModels reservationModel = new ReservationModels(); // permet d'effectuer une requete pour avoir l'emploi du temps

            // On charge l'utilisateur choisi par le select enseignant
            ViewBag.listeEnseignant = db.ENSEIGNANTs.ToList();
            if (id != 0)
            {
                enseignant = db.ENSEIGNANTs.Find(id);
                if (enseignant != null)
                {
                    ensSelectionEstNul = false;
                }
            }

            // Si l'enseignant n'est pas nul alors on fait la requête pour avoir son emploi du temps
            // Sinon on charge l'emploi du temps de l'utilisateur courant
            if (!ensSelectionEstNul)
            {
                // requete permettant de récupérer l'emploi du temps de l'utilisateur sélectionné
                var query = from res in db.RESERVATIONs
                            where res.ENSEIGNEMENT.ENSEIGNANT.LOGIN == enseignant.LOGIN
                            select res;

                var liste_va = from r in query
                               where r.STATUS == 1
                               select r;
                reservationModel.reservations_valides = liste_va.ToList<RESERVATION>();
            }
            else
            {
                // requete permettant de récupérer l'emploi du temps de l'utilisateur connecté
                string username = WebSecurity.CurrentUserName;

                var query = from res in db.RESERVATIONs
                            where res.ENSEIGNEMENT.ENSEIGNANT.LOGIN == username
                            select res;

                var liste_va = from r in query
                               where r.STATUS == 1
                               select r;
                reservationModel.reservations_valides = liste_va.ToList<RESERVATION>();
            }

            // Permet de structurer le code que l'on transmettra au Jquery pour l'affichage

            string boucle_nom_du_cours;
            string[] boucle_heure_minute_debut;
            string[] boucle_heure_minute_fin;
            string boucle_date_debut_annee;
            string boucle_date_debut_mois;
            string boucle_date_debut_jour;

            string ensemble_reservation = "{ header: {left: 'prev,next today', center: 'title',right: 'month,agendaWeek,agendaDay' },editable: false, events: [";

            int nombre_iteration = reservationModel.reservations_valides.Count;
            int iteration_courant = 0;

            foreach (RESERVATION i in reservationModel.reservations_valides)
            {
                iteration_courant++;
                boucle_nom_du_cours = i.ENSEIGNEMENT.COUR.LIBELLE_COURS;
                boucle_date_debut_annee = i.DATE_RESERVATION.Year.ToString();
                boucle_date_debut_mois = (i.DATE_RESERVATION.Month-1).ToString();
                boucle_date_debut_jour = i.DATE_RESERVATION.Day.ToString();
                boucle_heure_minute_debut = i.CRENAUX.HEURE_DEBUT.Split(new string[] { "h" }, StringSplitOptions.None);
                boucle_heure_minute_fin = i.CRENAUX.HEURE_FIN.Split(new string[] { "h" }, StringSplitOptions.None);

                if (iteration_courant < nombre_iteration)
                {

                    ensemble_reservation += "{ title: '" + boucle_nom_du_cours + "', " +
                        "start : new Date(" +
                        boucle_date_debut_annee + "," + boucle_date_debut_mois + "," + boucle_date_debut_jour + "," + boucle_heure_minute_debut[0] + "," + boucle_heure_minute_debut[1] + ")," +
                        "end : new Date(" +
                        boucle_date_debut_annee + "," + boucle_date_debut_mois + "," + boucle_date_debut_jour + "," + boucle_heure_minute_fin[0] + "," + boucle_heure_minute_fin[1] + ")," +
                        "allDay:false },";

                }
                else
                {
                    ensemble_reservation += "{ title: '" + boucle_nom_du_cours + "', " +
                                            "start : new Date(" +
                                            boucle_date_debut_annee + "," + boucle_date_debut_mois + "," + boucle_date_debut_jour + "," + boucle_heure_minute_debut[0] + "," + boucle_heure_minute_debut[1] + ")," +
                                            "end : new Date(" +
                                            boucle_date_debut_annee + "," + boucle_date_debut_mois + "," + boucle_date_debut_jour + "," + boucle_heure_minute_fin[0] + "," + boucle_heure_minute_fin[1] + ")," +
                                            "allDay:false }";
                }

            }
            ensemble_reservation = ensemble_reservation + "]}";
            ViewData["EDT"] = ensemble_reservation;
            //ViewBag.EDT = ensemble_reservation;

            ViewData["Enseignantss"] = new SelectList(db.ENSEIGNANTs.ToList(),"ID_ENSEIGNANT", "NOM" );
            ViewBag.listeenseignant1 = new SelectList(db.ENSEIGNANTs.ToList(), "NOM", "LOGIN");
            // fin de la fonction, on retourne la vue
            return View();
        }
Exemplo n.º 4
0
        public ActionResult Soumettre(ReservationModels reservationModel)
        {
            //if (ModelState.IsValid)
            if(reservationModel.RESERVATION.ID_CRENEAU!=0&&reservationModel.RESERVATION.ID_ENSEIGNEMENT!=0&&reservationModel.RESERVATION.DATE_STRING!=null&&reservationModel.RESERVATION.ID_SALLE!=0)
            {
                try
                {
                    reservationModel.RESERVATION.STATUS = 0;
                    DateTime temp = reservationModel.RESERVATION.DATE_RESERVATION;
                    reservationModel.RESERVATION.DATE_RESERVATION = DateTime.ParseExact(reservationModel.RESERVATION.DATE_STRING, "dd/MM/yyyy", null);
                    System.Diagnostics.Debug.WriteLine(reservationModel.RESERVATION.DATE_RESERVATION.ToString());

                    db.RESERVATIONs.Add(reservationModel.RESERVATION);

                    try
                    {
                        db.SaveChanges();
                    }
                    catch (DbEntityValidationException dbEx)
                    {
                        foreach (var validationErrors in dbEx.EntityValidationErrors)
                        {
                            foreach (var validationError in validationErrors.ValidationErrors)
                            {
                                Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
                            }
                        }
                    }

                    return RedirectToAction("Index");

                }catch(FormatException ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex.ToString());
                    return RedirectToAction("Erreur", new { error_message = "Internal Server Error", REQUEST_PATH="/Reservation/Ajouter"});
                }
            }

            return RedirectToAction("Erreur", new { error_message = "vous devez fournir des informations correctes", REQUEST_PATH = "/Reservation/Ajouter" });
        }
Exemplo n.º 5
0
 public ActionResult test()
 {
     ReservationModels rs = new ReservationModels();
     ViewBag.model = rs;
     return View();
 }
Exemplo n.º 6
0
        public ActionResult Accepter_OR_Refuser(string submitButton1, string submitButton2, ReservationModels reservationModel)
        {
            List<RESERVATION> liste_res_a_modifier = new List<RESERVATION>();
            foreach (var c in reservationModel.CheckBoxItems)
            {
                System.Diagnostics.Debug.WriteLine("HA" + c.IsChecked+"HA"+c.Code);

                if (c.IsChecked == true)
                {
                    liste_res_a_modifier.Add(db.RESERVATIONs.Find(c.Code));
                }
            }
            var button_name = submitButton1 ?? submitButton2;//NOTE THIS LINE!!
            if (button_name.Equals("flag_accepter"))//Decide wether can accept or not?
            {

                int count_fail = 0;

                for (int i = 0; i < liste_res_a_modifier.Count(); i++)
                {

                    RESERVATION res_a_decider = liste_res_a_modifier.ElementAt(i);

                    var vailde_res = from rs in db.RESERVATIONs
                                     where rs.STATUS == 1
                                     select rs;

                    List<RESERVATION> vailde_res_liste = vailde_res.ToList<RESERVATION>();

                    if (vailde_res_liste.Count() == 0)
                    {
                        res_a_decider.STATUS = 1;
                    }

                    for (int j = 0; j < vailde_res_liste.Count(); j++)
                    {

                        if (res_a_decider.DATE_RESERVATION == vailde_res_liste.ElementAt(j).DATE_RESERVATION)
                        {
                            if (res_a_decider.ID_CRENEAU == vailde_res_liste.ElementAt(j).ID_CRENEAU)
                            {
                                if (res_a_decider.ID_SALLE == vailde_res_liste.ElementAt(j).ID_SALLE)
                                {
                                    res_a_decider.STATUS = 0;
                                    count_fail++;
                                    break;
                                }

                            }

                        }
                        res_a_decider.STATUS = 1;
                    }

                    try{
                        db.SaveChanges();
                    }
                    catch (DbEntityValidationException dbEx)
                    {
                        foreach (var validationErrors in dbEx.EntityValidationErrors)
                        {
                            foreach (var validationError in validationErrors.ValidationErrors)
                            {
                                Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
                            }
                        }
                    }

                }

                System.Diagnostics.Debug.WriteLine("fails in total is " + count_fail);

            }
            else if (button_name.Equals("flag_refuser"))
            {
                foreach (var r in liste_res_a_modifier)
                {
                    r.STATUS = 2;

                    try
                    {
                        db.SaveChanges();
                    }
                    catch (DbEntityValidationException dbEx)
                    {
                        foreach (var validationErrors in dbEx.EntityValidationErrors)
                        {
                            foreach (var validationError in validationErrors.ValidationErrors)
                            {
                                Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
                            }
                        }
                    }

                }
            }

            return RedirectToAction("Index");
        }
Exemplo n.º 7
0
        public ActionResult Index()
        {
            ReservationModels reservationModel = new ReservationModels();

            var query = from res in db.RESERVATIONs
            select res;

            var liste_va = from r in query
                           where r.STATUS == 1
                           select r;
            reservationModel.reservations_valides = liste_va.ToList<RESERVATION>();

            var liste_ea = from r in query
                           where r.STATUS == 0
                           select r;
            reservationModel.reservations_enattentes = liste_ea.ToList<RESERVATION>();

            var liste_rf = from r in query
                           where r.STATUS == 2
                           select r;
            reservationModel.reservations_refuses = liste_rf.ToList<RESERVATION>();

            reservationModel.CheckBoxItems=new List<CheckBoxItem>();
            foreach (var ea in reservationModel.reservations_enattentes)
            {
                reservationModel.CheckBoxItems.Add(new CheckBoxItem { IsChecked=false});
            }

            return View(reservationModel);
        }