Exemplo n.º 1
0
        public ActionResult InscriptionJour(int id = 0)
        {
            InscritsView view = new InscritsView();

            List <Participant> partipants = MgtParticipant.GetInstance().GetAllByIdCourse(id);

            view.Course       = MgtRace.GetInstance().GetRace(id).ToModel();
            view.inscriptions = initInscriptions(partipants);

            return(View(view));
        }
Exemplo n.º 2
0
        public ActionResult InscritsToPDF(int id)
        {
            InscritsView view = new InscritsView();

            List <Participant>   partipants = MgtParticipant.GetInstance().GetAllByIdCourse(id);
            List <PersonneModel> personnes  = new List <PersonneModel>();

            foreach (Participant part in partipants)
            {
                PersonneModel model = MgtPersonne.GetInstance().GetPersonneById(part.IdPersonne).ToModel();
                model.participant = part.ToModel();
                personnes.Add(model);
            }

            view.Course       = MgtRace.GetInstance().GetRace(id).ToModel();
            view.personnes    = personnes;
            view.nbInscrits   = personnes.Count;
            view.inscriptions = initInscriptions(partipants);

            Document   doc    = new Document(PageSize.LETTER, 50, 50, 50, 50);
            string     html   = RenderRazorViewToString("~/Views/Race/InscritsToPDF.cshtml", view);
            TextReader reader = new StringReader(html);

            using (MemoryStream output = new MemoryStream())
            {
                PdfWriter wri = PdfWriter.GetInstance(doc, output);

                // step 3: we create a worker parse the document
                HTMLWorker worker = new HTMLWorker(doc);

                doc.Open();

                worker.StartDocument();

                // step 5: parse the html into the document
                worker.Parse(reader);

                // step 6: close the document and the worker
                worker.EndDocument();
                worker.Close();

                doc.Close();
                return(File(output.ToArray(), "application/pdf", "Inscriptions" + view.Course.Title + ".pdf"));
            }
        }
Exemplo n.º 3
0
        public ActionResult Inscrits(int id = 0, int page = 1)
        {
            InscritsView view = new InscritsView();

            List <Participant>   partipants = MgtParticipant.GetInstance().GetAllByIdCourse(id);
            List <PersonneModel> personnes  = new List <PersonneModel>();

            foreach (Participant part in partipants)
            {
                PersonneModel model = MgtPersonne.GetInstance().GetPersonneById(part.IdPersonne).ToModel();
                model.participant = part.ToModel();
                personnes.Add(model);
            }

            Pager pager = new Pager(personnes.Count, page, 15);

            view.Course       = MgtRace.GetInstance().GetRace(id).ToModel();
            view.personnes    = personnes.Skip((pager.CurrentPage - 1) * pager.PageSize).Take(pager.PageSize).ToList();
            view.nbInscrits   = personnes.Count;
            view.inscriptions = initInscriptions(partipants);
            view.Pager        = pager;

            return(View(view));
        }
Exemplo n.º 4
0
        public ActionResult InscriptionAge(int id = 0)
        {
            InscritsView view = new InscritsView();

            List <Participant>   partipants = MgtParticipant.GetInstance().GetAllByIdCourse(id);
            List <PersonneModel> personnes  = new List <PersonneModel>();

            int Nb20    = 0;
            int Nb21_30 = 0;
            int Nb31_40 = 0;
            int Nb41_50 = 0;
            int Nb51_60 = 0;
            int Nb61    = 0;

            foreach (Participant part in partipants)
            {
                PersonneModel model = MgtPersonne.GetInstance().GetPersonneById(part.IdPersonne).ToModel();
                if (model.DateNaissance != null)
                {
                    int age = DateTime.Now.Year - model.DateNaissance.Value.Year;
                    if (age <= 20)
                    {
                        Nb20++;
                    }
                    else if (age <= 30)
                    {
                        Nb21_30++;
                    }
                    else if (age <= 40)
                    {
                        Nb31_40++;
                    }
                    else if (age <= 50)
                    {
                        Nb41_50++;
                    }
                    else if (age <= 60)
                    {
                        Nb51_60++;
                    }
                    else
                    {
                        Nb61++;
                    }
                }

                personnes.Add(model);
            }

            view.Course     = MgtRace.GetInstance().GetRace(id).ToModel();
            view.personnes  = personnes;
            view.nbInscrits = personnes.Count;

            view.TA20    = Nb20;
            view.TA21_30 = Nb21_30;
            view.TA31_40 = Nb31_40;
            view.TA41_50 = Nb41_50;
            view.TA51_60 = Nb51_60;
            view.TA61    = Nb61;

            return(View(view));
        }