public async Task <IActionResult> ExportCalendar(string id)
        {
            var _ApplicantSessionController = new ApplicantSessionController(_context);
            var _formationController        = new FormationController(_context);
            IEnumerable <applicant_session> getApplicantSession = await _ApplicantSessionController.GetApplicantSession(id);

            var calendar = new Calendar();

            foreach (var item in getApplicantSession.ToList())
            {
                var f = _formationController.GetFormation(item.idFormation).Result.Value;
                calendar.Events.Add(new CalendarEvent
                {
                    Class       = "PUBLIC",
                    Summary     = f.Name,
                    Created     = new CalDateTime(DateTime.Now),
                    Start       = new CalDateTime(f.StartDate),
                    End         = new CalDateTime(f.EndDate),
                    Description = f.Description,
                    Location    = f.Location,
                    Organizer   = new Organizer
                    {
                        CommonName = f.OrganizationName + " : " + f.Former,
                    },
                });
            }

            var serializer         = new CalendarSerializer();
            var serializedCalendar = serializer.SerializeToString(calendar);
            var bytesCalendar      = System.Text.Encoding.UTF8.GetBytes(serializedCalendar);

            return(File(bytesCalendar, "application/octet-stream", "calendar.ics"));
        }
        public async Task <ActionResult <applicant_session> > RegisterUserformation(applicant_session RegisterUser)
        {
            FormationController        _formationController = new FormationController(_context);
            ApplicantSessionController _sessionController   = new ApplicantSessionController(_context);
            var searchedForm = await _formationController.GetFormation(RegisterUser.idFormation);

            if (searchedForm == null)
            {
                return(NotFound());
            }
            return(await _sessionController.PostApplicantSession(RegisterUser));
        }
        public async Task <ActionResult <IEnumerable <formation> > > GetUserFormation(String id)
        {
            var _ApplicantSessionController = new ApplicantSessionController(_context);
            var _formationController        = new FormationController(_context);
            IEnumerable <applicant_session> getApplicantSession = await _ApplicantSessionController.GetApplicantSession(id);

            List <formation> Result = new List <formation>();

            foreach (var item in getApplicantSession.ToList())
            {
                Result.Add(_formationController
                           .GetFormation(item.idFormation)
                           .Result
                           .Value);
            }
            return(Result);
        }