servicios
This commit is contained in:
@@ -4,13 +4,8 @@ import 'package:prosappco/src/authentication/authentication_repository.dart';
|
||||
final uid = AuthenticationRepository.instance.getCurrentUserUid();
|
||||
|
||||
class EventoService {
|
||||
Future<void> createEvent(
|
||||
String title,
|
||||
String description,
|
||||
String day,
|
||||
String range1Hour1,
|
||||
String range1Hour2,
|
||||
) async {
|
||||
Future<void> createEvent(String title, String description, String day,
|
||||
String range1Hour1, String range1Hour2, String professionalId) async {
|
||||
try {
|
||||
await FirebaseFirestore.instance.collection('services').add({
|
||||
'user_id': uid,
|
||||
@@ -18,7 +13,8 @@ class EventoService {
|
||||
'description': description,
|
||||
'day': day,
|
||||
'range1Hour1': range1Hour1,
|
||||
'range1Hour2': range1Hour2
|
||||
'range1Hour2': range1Hour2,
|
||||
'professional_id': professionalId
|
||||
}).then((value) {
|
||||
FirebaseFirestore.instance.collection('users').doc(uid).update({
|
||||
'services': FieldValue.arrayUnion([value.id])
|
||||
@@ -34,7 +30,7 @@ Future<List<Event>> getByProId(String day) async {
|
||||
try {
|
||||
var snapshot = await FirebaseFirestore.instance
|
||||
.collection('services')
|
||||
.where('user_id', isEqualTo: uid)
|
||||
.where('professional_id', isEqualTo: uid)
|
||||
.where('day', isEqualTo: day.toString())
|
||||
.get();
|
||||
|
||||
@@ -57,6 +53,7 @@ class Event {
|
||||
String? range1Hour1;
|
||||
String? range1Hour2;
|
||||
String? userId;
|
||||
String? professionalId;
|
||||
|
||||
Event({
|
||||
this.title,
|
||||
@@ -65,6 +62,7 @@ class Event {
|
||||
this.range1Hour1,
|
||||
this.range1Hour2,
|
||||
this.userId,
|
||||
this.professionalId,
|
||||
});
|
||||
|
||||
factory Event.fromJson(Map<String, dynamic> json) {
|
||||
@@ -75,6 +73,7 @@ class Event {
|
||||
range1Hour1: json['range1Hour1'],
|
||||
range1Hour2: json['range1Hour2'],
|
||||
userId: json['user_id'],
|
||||
professionalId: json['professional_id'],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -82,7 +81,7 @@ class Event {
|
||||
try {
|
||||
var snapshot = await FirebaseFirestore.instance
|
||||
.collection('services')
|
||||
.where('user_id', isEqualTo: uid)
|
||||
.where('professional_id', isEqualTo: uid)
|
||||
.get();
|
||||
|
||||
List<Event> eventos = [];
|
||||
|
||||
Reference in New Issue
Block a user