Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2021-035-CoviDefender
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2021-035
2021-035-CoviDefender
Commits
cc56f1b7
Commit
cc56f1b7
authored
Jun 08, 2021
by
GayaniPKarunaratne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Done crud operations in Add location part
parent
218f8319
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
76 additions
and
16 deletions
+76
-16
lib/EAnalyzer/AddLocation.dart
lib/EAnalyzer/AddLocation.dart
+76
-16
No files found.
lib/EAnalyzer/AddLocation.dart
View file @
cc56f1b7
...
@@ -38,7 +38,7 @@ getDate(date){
...
@@ -38,7 +38,7 @@ getDate(date){
getTime
(
time
){
getTime
(
time
){
this
.
time
=
time
;
this
.
time
=
time
;
}
}
//---------------------------------------------Create Data-----------------------------------------------------
createData
(){
createData
(){
print
(
"object"
);
print
(
"object"
);
...
@@ -59,6 +59,9 @@ createData(){
...
@@ -59,6 +59,9 @@ createData(){
}
}
//---------------------------------------------Read Data-----------------------------------------------------
readData
(){
readData
(){
DocumentReference
documentReference
=
Firestore
.
instance
.
collection
(
"RiskLocation"
).
document
(
userName
);
DocumentReference
documentReference
=
Firestore
.
instance
.
collection
(
"RiskLocation"
).
document
(
userName
);
...
@@ -72,6 +75,36 @@ readData(){
...
@@ -72,6 +75,36 @@ readData(){
});
});
}
}
//---------------------------------------------Update Data-----------------------------------------------------
updateData
(){
print
(
"object"
);
DocumentReference
documentReference
=
Firestore
.
instance
.
collection
(
"RiskLocation"
).
document
(
userName
);
Map
<
String
,
dynamic
>
locations
={
"userName"
:
userName
,
"phoneNumber"
:
phoneNumber
,
"riskLocation"
:
riskLocation
,
"hotelName"
:
hotelName
,
"date"
:
date
,
"time"
:
time
};
documentReference
.
setData
(
locations
).
whenComplete
(()
{
print
(
"
$userName
Updated"
);
});
}
//---------------------------------------------Delete Data-----------------------------------------------------
deleteData
(){
DocumentReference
documentReference
=
Firestore
.
instance
.
collection
(
"RiskLocation"
).
document
(
userName
);
documentReference
.
delete
().
whenComplete
((){
print
(
"
$userName
Deleted"
);
});
}
final
GlobalKey
<
FormState
>
_formKey
=
GlobalKey
<
FormState
>();
final
GlobalKey
<
FormState
>
_formKey
=
GlobalKey
<
FormState
>();
//---------------------------------------------User Name-----------------------------------------------------
//---------------------------------------------User Name-----------------------------------------------------
Widget
_buildName
(
){
Widget
_buildName
(
){
...
@@ -210,33 +243,60 @@ Widget _buildTime(){
...
@@ -210,33 +243,60 @@ Widget _buildTime(){
SizedBox
(
height:
100
),
SizedBox
(
height:
100
),
RaisedButton
(
RaisedButton
(
color:
Colors
.
green
,
child:
Text
(
child:
Text
(
'Submit'
,
'Submit'
,
style:
TextStyle
(
color:
Colors
.
green
,
fontSize:
18
),
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
18
),
),
),
onPressed:
()
{
onPressed:
()
{
if
(!
_formKey
.
currentState
.
validate
())
{
if
(!
_formKey
.
currentState
.
validate
())
{
return
;
return
;
}
}
// _formKey.currentState.save();
createData
();
// print(_fName);
}
,
// print(_lName);
),
// print(_age);
// print(_address);
// print(_nic);
// print(_phoneNumber);
// print(_riskLocation);
// print(_hotelName);
// print(_date);
// print(_time);
createData
();
RaisedButton
(
color:
Colors
.
blue
,
child:
Text
(
'View'
,
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
18
),
),
onPressed:
()
{
readData
();
}
,
}
,
)
),
RaisedButton
(
color:
Colors
.
yellowAccent
[
700
],
child:
Text
(
'Update'
,
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
18
),
),
onPressed:
()
{
updateData
();
}
,
),
RaisedButton
(
color:
Colors
.
red
,
child:
Text
(
'Delete'
,
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
18
),
),
onPressed:
()
{
deleteData
();
}
,
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment