lista de servicios
This commit is contained in:
+17
@@ -189,4 +189,21 @@ class FirebaseProfessionalRepository {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<ProfessionalEntity>> getProfessionsFromIds(
|
||||
Iterable<String> ids) async {
|
||||
try {
|
||||
// Realizar una consulta única para obtener la información de todos los usuarios
|
||||
final querySnapshot = await professionalCollection
|
||||
.where(FieldPath.documentId, whereIn: ids)
|
||||
.get();
|
||||
|
||||
return querySnapshot.docs
|
||||
.map((e) => ProfessionalEntity.fromDocument(e.data()))
|
||||
.toList();
|
||||
} catch (e) {
|
||||
log('getProfessionsFromIds ${e.toString()}');
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,13 @@ class FirebaseServiceRepository {
|
||||
return docRef.id;
|
||||
}
|
||||
|
||||
Future<void> updateServiceStatus(
|
||||
String serviceId, ServiceStatus newStatus) async {
|
||||
await serviceCollection
|
||||
.doc(serviceId)
|
||||
.update({'status': enumToIntService(newStatus)});
|
||||
}
|
||||
|
||||
Stream<ServiceEntity> getService(String serviceId) {
|
||||
return serviceCollection.doc(serviceId).snapshots().map((snapshot) {
|
||||
if (snapshot.exists) {
|
||||
@@ -21,10 +28,12 @@ class FirebaseServiceRepository {
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> updateServiceStatus(
|
||||
String serviceId, ServiceStatus newStatus) async {
|
||||
await serviceCollection
|
||||
.doc(serviceId)
|
||||
.update({'status': enumToIntService(newStatus)});
|
||||
Stream<List<ServiceEntity>> getServicesForUser(String userId) {
|
||||
return serviceCollection
|
||||
.where('user_id', isEqualTo: userId)
|
||||
.snapshots()
|
||||
.map((querySnapshot) => querySnapshot.docs
|
||||
.map((doc) => ServiceEntity.fromDocument(doc.data()))
|
||||
.toList());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -403,4 +403,20 @@ class FirebaseUserRepository implements UserRepository {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<MyUser>> getUsersFromIds(Iterable<String> ids) async {
|
||||
try {
|
||||
// Realizar una consulta única para obtener la información de todos los usuarios
|
||||
final querySnapshot =
|
||||
await usersCollection.where(FieldPath.documentId, whereIn: ids).get();
|
||||
|
||||
return querySnapshot.docs
|
||||
.map((e) => MyUser.fromEntity(MyUserEntity.fromDocument(e.data())))
|
||||
.toList();
|
||||
} catch (e) {
|
||||
log('getUsersFromIds ${e.toString()}');
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +45,8 @@ abstract class UserRepository {
|
||||
Future<void> createUser(MyUser myUser);
|
||||
|
||||
Future<List<MyUser>> getUsersProfessionalActive();
|
||||
|
||||
Future<List<MyUser>> getUsersFromIds(Iterable<String> ids);
|
||||
}
|
||||
|
||||
enum UpdatePassworErros { credentialsWrong, userNotFound, unknown }
|
||||
|
||||
Reference in New Issue
Block a user