Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AtClub
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
DAI Leslie
AtClub
Commits
b3d2499b
Commit
b3d2499b
authored
1 year ago
by
RENAULT Juliette
Browse files
Options
Downloads
Patches
Plain Diff
modification club qui marche avec update des nouveaux prez et de la description
parent
849059fb
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
atlub/lib/Pages/Formulaires/modify_club2.0.dart
+3
-3
3 additions, 3 deletions
atlub/lib/Pages/Formulaires/modify_club2.0.dart
atlub/lib/Services/database.dart
+61
-17
61 additions, 17 deletions
atlub/lib/Services/database.dart
with
64 additions
and
20 deletions
atlub/lib/Pages/Formulaires/modify_club2.0.dart
+
3
−
3
View file @
b3d2499b
...
...
@@ -120,14 +120,14 @@ class _ModClubState extends State<ModClub> {
database
.
updateclub
(
widget
.
idClub
,
selectedBDXType
,
club
,
descrip
);
Future
<
String
?
>
idprez
=
database
.
getProfilIdFromName
(
prez
);
Future
<
String
?
>
idprez
=
database
.
getProfilIdFrom
Full
Name
(
prez
);
bool
prezOk
=
false
;
Future
<
String
?
>
idcoprez
=
database
.
getProfilIdFromName
(
coprez
);
Future
<
String
?
>
idcoprez
=
database
.
getProfilIdFrom
Full
Name
(
coprez
);
Future
.
wait
([
idprez
,
idcoprez
])
.
then
((
List
<
dynamic
?
>
results
)
{
String
?
idprez
=
results
[
0
]
as
String
?
;
// ID du profil
print
(
idprez
);
String
?
idcoprez
=
results
[
1
]
as
String
?
;
print
(
prez
);
print
(
idco
prez
);
// Vérifier si les IDs de président ne sont pas nuls avant de les utiliser
...
...
This diff is collapsed.
Click to expand it.
atlub/lib/Services/database.dart
+
61
−
17
View file @
b3d2499b
...
...
@@ -545,15 +545,16 @@ class DatabaseService {
try
{
// Référence au document à supprimer
String
idPresident
=
await
getPresidentClubid
(
idclub
,
type
);
DocumentReference
documentReference
=
FirebaseFirestore
.
instance
.
collection
(
'Presidents'
)
.
doc
(
idPresident
);
if
(
idPresident
.
isNotEmpty
)
{
DocumentReference
documentReference
=
FirebaseFirestore
.
instance
.
collection
(
'Presidents'
)
.
doc
(
idPresident
);
// Supprimer le document
await
documentReference
.
delete
();
print
(
'Document
$idPresident
supprimé avec succès.'
);
addPresident
(
idprofil
,
idclub
,
type
);
}
// Ajouter le nouveau président
await
addPresident
(
idprofil
,
idclub
,
type
);
}
catch
(
error
)
{
print
(
'Erreur lors de la suppression du document :
$error
'
);
// Gérer l'erreur selon votre besoin
...
...
@@ -759,25 +760,68 @@ class DatabaseService {
// Récupérer l'id d'un profil à partir de son nom
Future
<
String
?
>
getProfilIdFromName
(
String
pre
nom
)
async
{
String
?
pre
nomId
;
Future
<
String
?
>
getProfilIdFromName
(
String
nom
)
async
{
String
?
nomId
;
QuerySnapshot
querySnapshot
=
await
FirebaseFirestore
.
instance
.
collection
(
'Profils'
)
.
where
(
'prenom'
,
isEqualTo:
pre
nom
)
.
where
(
'prenom'
,
isEqualTo:
nom
)
.
limit
(
1
)
// Nous ne récupérons qu'un seul document
.
get
();
if
(
querySnapshot
.
docs
.
isNotEmpty
)
{
pre
nomId
=
querySnapshot
.
docs
.
first
.
id
;
nomId
=
querySnapshot
.
docs
.
first
.
id
;
}
else
{
pre
nomId
=
null
;
nomId
=
null
;
}
return
pre
nomId
;
return
nomId
;
}
// Récupérer l'id d'un profil à partir de son nom complet
Future
<
String
?
>
getProfilIdFromFullName
(
String
fullName
)
async
{
String
?
nomId
;
// Séparer le nom complet en prénom et nom
List
<
String
>
nameParts
=
fullName
.
split
(
' '
);
if
(
nameParts
.
length
!=
2
)
{
throw
Exception
(
"Le nom complet doit contenir exactement deux parties : prénom et nom."
);
}
String
prenom
=
nameParts
[
0
];
String
nom
=
nameParts
[
1
];
// Rechercher le profil par prénom et nom dans l'ordre "prenom nom"
QuerySnapshot
querySnapshot
=
await
FirebaseFirestore
.
instance
.
collection
(
'Profils'
)
.
where
(
'prenom'
,
isEqualTo:
prenom
)
.
where
(
'nom'
,
isEqualTo:
nom
)
.
limit
(
1
)
.
get
();
if
(
querySnapshot
.
docs
.
isNotEmpty
)
{
nomId
=
querySnapshot
.
docs
.
first
.
id
;
}
else
{
// Rechercher le profil par prénom et nom dans l'ordre "nom prenom"
querySnapshot
=
await
FirebaseFirestore
.
instance
.
collection
(
'Profils'
)
.
where
(
'prenom'
,
isEqualTo:
nom
)
.
where
(
'nom'
,
isEqualTo:
prenom
)
.
limit
(
1
)
.
get
();
if
(
querySnapshot
.
docs
.
isNotEmpty
)
{
nomId
=
querySnapshot
.
docs
.
first
.
id
;
}
else
{
nomId
=
null
;
}
}
return
nomId
;
}
Future
<
String
>
getUserName
(
String
uid
)
async
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment