// Signging the PDF for the integration public async Task <bool> SignFicheIntegrationAsync(string currentUserId, string coachId) { Coach coach = await GetCoachFromCoachId(coachId); if (coach == null || coach.UserId != currentUserId) { throw new UnauthorizedAccessException("You are not the user corresponding to the coach"); } User user = await(await _users.FindAsync(databaseUser => databaseUser.Id == coach.UserId )).FirstOrDefaultAsync(); if (user == null) { throw new Exception("The user doesn't exist..."); } PdfIntegrationCoach pdfIntegrationCoach = new PdfIntegrationCoach() { FirstName = user.FirstName, LastName = user.LastName, Birthdate = user.Birthdate, BirthPlace = user.BirthPlace, Email = user.Email, Phone = user.Phone, DiscordTag = user.DiscordTag, LinkedIn = user.LinkedIn, City = user.City, PostalCode = user.PostalCode, Address = user.Address, Situation = coach.Situation, Keywords = await _formsService.GetAnswerForQuestionAsync(currentUserId, "Quels sont les mots clés qui te définissent ?"), Experience = await _formsService.GetAnswerForQuestionAsync(currentUserId, "Quelles sont tes expériences professionnelles et personnelles ? "), IdealBuilder = await _formsService.GetAnswerForQuestionAsync(currentUserId, "Quel serait le Builder idéal pour toi ?"), Objectifs = await _formsService.GetAnswerForQuestionAsync(currentUserId, "Quels objectifs souhaites-tu que ton Builder atteignent au bout des 3 mois ?"), }; if (_pdfService.SignCoachIntegration(coachId, pdfIntegrationCoach)) { var update = Builders <Coach> .Update .Set(dbCoach => dbCoach.HasSignedFicheIntegration, true); var coachCard = _pdfService.GenerateCoachCard(coachId, new PdfCoachCard() { FirstName = user.FirstName, LastName = user.LastName, Birthdate = user.Birthdate, ValidityDate = coach.CandidatingDate.AddYears(1) }); var fileId = await _filesService.UploadFile($"coachcard_{coachId}", coachCard); update = update.Set(dbCoach => dbCoach.CoachCardId, fileId); await _coachs.UpdateOneAsync(databaseCoach => databaseCoach.Id == coachId, update ); await _notificationService.NotifySignedIntegrationPaperCoach(coachId, user.Email, user.FirstName); return(true); } return(false); }