Esempio n. 1
0
        /// <summary>
        /// Constructeur de la page d'accueil
        /// </summary>
        /// <param name="utilisateurRepository"></param>
        /// <param name="courseRepository"></param>
        /// <param name="resultatRepository"></param>
        /// <param name="coureurRepository"></param>
        public Accueil(UtilisateurRepository utilisateurRepository, CourseRepository courseRepository, ResultatRepository resultatRepository, CoureurRepository coureurRepository)
        {
            InitializeComponent();
            this.utilisateurRepository = utilisateurRepository;
            this.courseRepository      = courseRepository;
            this.resultatRepository    = resultatRepository;
            this.coureurRepository     = coureurRepository;

            // Changements des états des boutons car non connecté
            this.buttonAjouterCourse.Visible   = false;
            this.buttonAjouterCourse.Enabled   = false;
            this.buttonImportCoureurs.Visible  = false;
            this.buttonImportCoureurs.Enabled  = false;
            this.buttonNouveauCoureur.Visible  = false;
            this.buttonNouveauCoureur.Enabled  = false;
            this.buttonModifierCourse.Visible  = false;
            this.buttonModifierCourse.Enabled  = false;
            this.buttonImportResultats.Visible = false;
            this.buttonImportResultats.Enabled = false;
            this.buttonSuppression.Visible     = false;
            this.buttonSuppression.Enabled     = false;

            // Remplit les dataGridViews
            AfficherContenu();
        }
Esempio n. 2
0
 static public void UpdateoneResultat(Resultat res)
 {
     using (ResultatRepository resultatrepo = new ResultatRepository())
     {
         resultatrepo.Update(res);
     }
 }
Esempio n. 3
0
        public void GetAllTest()
        {
            string attendu = "Participant : Jean - Course : 300";

            // Sauvegarde du participant
            Participant           p  = new Participant("Jean", "Claude", "jc", new DateTime(2001, 01, 01), "M");
            Participant           p2 = new Participant("Van", "Dam", "vd", new DateTime(2001, 01, 01), "M");
            ParticipantRepository pr = new ParticipantRepository();

            pr.Save(p);
            pr.Save(p2);
            List <Participant> participants = pr.GetAll();

            //Sauvegarde de la course
            Course           c  = new Course(300);
            CourseRepository cr = new CourseRepository();

            cr.Save(c);
            List <Course> courses = cr.GetAll();

            //Sauvegarde du résultat
            Resultat r  = new Resultat(p, c, new DateTime(2001, 10, 10, 00, 00, 23));
            Resultat r2 = new Resultat(p2, c, new DateTime(2001, 10, 10, 00, 00, 55));

            c.ClasserResultats();
            ResultatRepository rr = new ResultatRepository();

            rr.Save(r);
            rr.Save(r2);
            List <Resultat> resultats = rr.GetAll();
            string          sortie    = r.ToString();

            //test
            Assert.AreEqual(attendu, sortie);
        }
Esempio n. 4
0
        static public void AddResultats(ResultsViewModel resultvm)
        {
            using (ResultatRepository resultatrepo = new ResultatRepository())
            {
                //geeting the audit and setting it to modified automatically
                resultatrepo.context.Entry(resultvm.audit).State = EntityState.Modified;

                //geeting the themes and the points and setting it to unchanged so it wont be readded to the database that will be hell oh no no
                resultvm.themes = ServiceTheme.GetAllThemes();
                foreach (var item in resultvm.themes)
                {
                    resultatrepo.context.Entry(item).State = EntityState.Unchanged;
                }

                //a workaround to reattach the relations the results you can say that this is MAGIC
                int compteur = -1;
                foreach (var item in resultvm.themes)
                {
                    foreach (var inneritem in item.points)
                    {
                        compteur++;
                        resultvm.resultats[compteur].audit = resultvm.audit;
                        resultvm.resultats[compteur].theme = item;
                        resultvm.resultats[compteur].point = inneritem;
                        resultatrepo.Add(resultvm.resultats[compteur]);
                    }
                }
                resultatrepo.Save();
            }
        }
Esempio n. 5
0
 public Gestacourse()
 {
     InitializeComponent();
     Cr           = new CourseRepository();
     Rr           = new ResultatRepository();
     Pr           = new ParticipantRepository();
     ListeCourses = new List <Course>();
     Initialisation();
 }
 public ActionResult DeleteResultat(ResultatModels model)
 {
     using (ResultatRepository repository = new ResultatRepository())
     {
         repository.DeleteById(model.id);
         repository.Save();
     }
     return(View("Index"));
 }
Esempio n. 7
0
        static public Resultat getresultatbyCriteria(Audit audit, Theme theme, Point point)
        {
            Resultat temp;

            using (ResultatRepository resultatrepo = new ResultatRepository())
            {
                temp = resultatrepo.GetSingleByAuThPnt(audit, theme, point);
                resultatrepo.context.Entry(temp).State = EntityState.Detached;
            }
            return(temp);
        }
Esempio n. 8
0
 public Importation(int mode, Course laCourse, Button bouton)
 {
     InitializeComponent();
     choix           = mode;
     course          = laCourse;
     Pr              = new ParticipantRepository();
     Rr              = new ResultatRepository();
     cr              = new CourseRepository();
     BoutonAModifier = bouton;
     Ofd             = new OpenFileDialog();
 }
Esempio n. 9
0
        static void Main()
        {
            UtilisateurRepository utilisateurRepository = new UtilisateurRepository();
            CourseRepository      courseRepository      = new CourseRepository();
            ResultatRepository    resultatRepository    = new ResultatRepository();
            CoureurRepository     coureurRepository     = new CoureurRepository();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Accueil accueil = new Accueil(utilisateurRepository, courseRepository, resultatRepository, coureurRepository);

            Application.Run(accueil);
        }
Esempio n. 10
0
        static public List <Resultat> getAuditresults(Audit audit)
        {
            List <Resultat> temp;

            using (ResultatRepository resultatrepo = new ResultatRepository())
            {
                temp = (List <Resultat>)resultatrepo.GetAuditResults(audit);
                foreach (var item in temp)
                {
                    resultatrepo.context.Entry(item).State = EntityState.Detached;
                }
            }
            return(temp);
        }
        public ActionResult EditResultat(ResultatModels model)
        {
            using (ResultatRepository repository = new ResultatRepository())
            {
                Results x = repository.GetResultById(model.id);
                x.Evaluation_Id = model.evaluationId;
                x.Note          = model.note;
                x.Pupil_Id      = model.pupilId;

                if (ModelState.IsValid)
                {
                    repository.Save();
                }
                return(RedirectToAction("ReadResultats"));
            }
        }
        // GET: /Eval/CreateResultat
        public ActionResult CreateResultat()
        {
            ResultatModels model;

            using (ResultatRepository repository = new ResultatRepository())
            {
                IQueryable <Evaluations> evaluations = repository.GetEvaluations();
                IQueryable <Pupils>      pupils      = repository.GetEleves();
                model = new ResultatModels
                {
                    mode        = -1,
                    eleves      = getListEleves(pupils),
                    evaluations = getListEvaluations(evaluations)
                };
            }
            return(View(model));
        }
 public ActionResult EditerResultats(ListeResultatsModels model)
 {
     foreach (var resultat in model.resultats)
     {
         using (ResultatRepository repository = new ResultatRepository())
         {
             Results r = repository.GetResultById(resultat.id);
             r.Pupil_Id      = resultat.pupilId;
             r.Note          = resultat.note;
             r.Evaluation_Id = resultat.evaluationId;
             if (ModelState.IsValid)
             {
                 repository.Save();
             }
         }
     }
     return(RedirectToAction("ReadEvaluations"));
 }
        // GET: /Eval/ReadResultats
        public ActionResult ReadResultats()
        {
            IList <ResultatModels> models = new List <ResultatModels>();

            using (ResultatRepository repository = new ResultatRepository())
            {
                IQueryable <Results> a = repository.All();

                models = repository.All().Select(x => new ResultatModels
                {
                    id           = x.Id,
                    evaluationId = x.Evaluation_Id,
                    note         = x.Note,
                    pupilId      = x.Pupil_Id
                }).ToList();
            }
            return(View(models));
        }
        public ActionResult ReadResultat(Guid id)
        {
            ResultatModels model;

            using (ResultatRepository repository = new ResultatRepository())
            {
                Results x = repository.GetResultById(id);
                if (x == null)
                {
                    return(HttpNotFound());
                }
                model = new ResultatModels
                {
                    id           = x.Id,
                    evaluationId = x.Evaluation_Id,
                    note         = x.Note,
                    pupilId      = x.Pupil_Id
                };
            }
            return(View(model));
        }
        public ActionResult CreateResultat(ResultatModels model)
        {
            if (ModelState.IsValid)
            {
                using (ResultatRepository repository = new ResultatRepository())
                {
                    Results a = new Results
                    {
                        Id            = Guid.NewGuid(),
                        Evaluation_Id = model.evaluationId,
                        Pupil_Id      = model.pupilId,
                        Note          = model.note
                    };

                    repository.Add(a);
                    repository.Save();
                }
                return(RedirectToAction("ReadEvaluations"));
            }
            return(View(model));
        }
        public ActionResult SaisirResultats(ListeResultatsModels model)
        {
            if (ModelState.IsValid)
            {
                foreach (var resultat in model.resultats)
                {
                    using (ResultatRepository repository = new ResultatRepository())
                    {
                        Results r = new Results
                        {
                            Id            = Guid.NewGuid(),
                            Pupil_Id      = resultat.pupilId,
                            Note          = resultat.note,
                            Evaluation_Id = resultat.evaluationId
                        };

                        repository.Add(r);
                        repository.Save();
                    }
                }
                return(RedirectToAction("ReadEvaluations"));
            }
            return(View(model));
        }
        public ActionResult EditResultat(Guid id)
        {
            ResultatModels model;

            using (ResultatRepository repository = new ResultatRepository())
            {
                Results x = repository.GetResultById(id);
                IQueryable <Evaluations> evaluations = repository.GetEvaluations();
                IQueryable <Pupils>      pupils      = repository.GetEleves();
                if (x == null)
                {
                    return(HttpNotFound());
                }
                model = new ResultatModels
                {
                    mode         = 0,
                    id           = x.Id,
                    evaluationId = x.Evaluation_Id,
                    note         = x.Note,
                    pupilId      = x.Pupil_Id
                };
            }
            return(View("CreateResultat", model));
        }
Esempio n. 19
0
        static public void UpdateResultats(ResultsViewModel resultvm)
        {
            using (ResultatRepository resultatrepo = new ResultatRepository())
            {
                //geeting the audit and setting it to unchanged so it wont be readded to the database that will be hell oh no no
                resultatrepo.context.Entry(resultvm.audit).State = EntityState.Unchanged;

                //geeting the themes and the points and setting it to unchanged so it wont be readded to the database that will be hell oh no no
                resultvm.themes = ServiceTheme.GetAllThemes(resultvm.audit);
                foreach (var item in resultvm.themes)
                {
                    resultatrepo.context.Entry(item).State = EntityState.Unchanged;
                }



                List <int> ResultPoints = new List <int>();
                foreach (var item in resultvm.audit.resultats)
                {
                    ResultPoints.Add(item.point.PointID);
                }
                List <Point> PointTemp1 = new List <Point>();

                //foreach (var item in ServicePoint.GetAllPoints())
                //{

                //}

                foreach (var theme in resultvm.themes)
                {
                    PointTemp1.Clear();
                    foreach (var item1 in theme.points)
                    {
                        PointTemp1.Add(item1);
                    }
                    //for (int i = 0; i < PointTemp1.Count; i++)
                    //{
                    //    if (!ResultPoints.Contains(point.PointID))
                    //    {
                    //        theme.points.Remove(point);
                    //    }
                    //}
                    foreach (var point in PointTemp1)
                    {
                        if (!ResultPoints.Contains(point.PointID))
                        {
                            theme.points.Remove(point);
                        }
                    }
                }



                //getting the results from the database and updating them
                Resultat tempresultat = null;
                int      compteur     = -1;
                foreach (var item in resultvm.themes)
                {
                    foreach (var inneritem in item.points)
                    {
                        compteur++;
                        tempresultat             = ServiceResultat.getresultatbyCriteria(resultvm.audit, item, inneritem);
                        tempresultat.audit       = resultvm.audit;
                        tempresultat.theme       = item;
                        tempresultat.point       = inneritem;
                        tempresultat.Note        = resultvm.resultats[compteur].Note;
                        tempresultat.req_comment = resultvm.resultats[compteur].req_comment;

                        resultatrepo.Update(tempresultat);
                    }
                }
                resultatrepo.Save();
            }
        }