public async Task <List <Event> > GetUserEventByDateRange(string username, DateTime startDate, DateTime endDate) { List <Event> result = new List <Event>(); if (!string.IsNullOrEmpty(username)) { try { IQuerySnapshot querySnapshot = await _firestore.GetCollection(nameof(Event)) .WhereArrayContains(nameof(Event.UsersList), username) .WhereGreaterThanOrEqualsTo(nameof(Event.StartDateTime), startDate) .WhereLessThanOrEqualsTo(nameof(Event.StartDateTime), endDate) .GetDocumentsAsync(); foreach (IDocumentSnapshot documentSnapshot in querySnapshot.Documents) { if (documentSnapshot.Exists) { Event newEvent = documentSnapshot.ToObject <Event>(); result.Add(newEvent); } } } catch (Exception e) { result = null; App.LogException(e); } } return(result); }
public async Task <ObservableCollection <Event> > GetPastEventListAsync() { ObservableCollection <Event> result = new ObservableCollection <Event>(); try { IQuerySnapshot querySnapshot = await _firestore.GetCollection(nameof(Event)) .WhereLessThan(nameof(Event.StartDateTime), DateTime.Now) .OrderBy(nameof(Event.StartDateTime), true) .LimitTo(20) .GetDocumentsAsync(); foreach (IDocumentSnapshot documentSnapshot in querySnapshot.Documents) { if (documentSnapshot.Exists) { Event newEvent = documentSnapshot.ToObject <Event>(); result.Add(newEvent); } } } catch (Exception e) { result = null; App.LogException(e); } return(result); }
public async Task <ObservableCollection <Event> > GetNextEventListByParticipantUsername(string username, Event evento) { ObservableCollection <Event> result = new ObservableCollection <Event>(); try { IDocumentSnapshot documentSnapshotLast = await _firestore.GetCollection(nameof(Event)).GetDocument(evento.Id).GetDocumentAsync(); if (documentSnapshotLast != null) { IQuerySnapshot querySnapshot = await _firestore.GetCollection(nameof(Event)) .WhereArrayContains(nameof(Event.UsersList), username) .OrderBy(nameof(Event.StartDateTime), true) .StartAfter(documentSnapshotLast) .LimitTo(20) .GetDocumentsAsync(); foreach (IDocumentSnapshot documentSnapshot in querySnapshot.Documents) { if (documentSnapshot.Exists) { Event newEvent = documentSnapshot.ToObject <Event>(); result.Add(newEvent); } } } } catch (Exception e) { result = null; App.LogException(e); } return(result); }
public async Task <ObservableCollection <User> > GetUsersListByUsernameListAsync(List <string> usernameLists) { ObservableCollection <User> result = new ObservableCollection <User>(); if (usernameLists != null && usernameLists.Count > 0) { try { IQuerySnapshot querySnapshot = await _firestore.GetCollection(nameof(User)).GetDocumentsAsync(); foreach (IDocumentSnapshot documentSnapshot in querySnapshot.Documents) { if (documentSnapshot.Exists) { User newUser = documentSnapshot.ToObject <User>(); if (usernameLists.Contains(newUser.Email)) { result.Add(newUser); } } } } catch (Exception e) { result = new ObservableCollection <User>(); App.LogException(e); } } return(result); }
public async Task <ObservableCollection <User> > GetUserListAsync() { ObservableCollection <User> result = new ObservableCollection <User>(); try { IQuerySnapshot querySnapshot = await _firestore.GetCollection(nameof(User)).GetDocumentsAsync(); foreach (IDocumentSnapshot documentSnapshot in querySnapshot.Documents) { if (documentSnapshot.Exists) { User newUser = documentSnapshot.ToObject <User>(); result.Add(newUser); } } } catch (Exception e) { result = null; App.LogException(e); } return(result); }
public async Task <User> GetUserByPresenceIdAsync(string presenceId) { User result = null; if (!string.IsNullOrEmpty(presenceId)) { try { IQuerySnapshot querySnapshot = await _firestore.GetCollection(nameof(User)).WhereEqualsTo(nameof(User.PresenceId), presenceId).GetDocumentsAsync(); IDocumentSnapshot documentSnapshot = querySnapshot.Documents.FirstOrDefault(); if (documentSnapshot.Exists) { result = documentSnapshot.ToObject <User>(); } } catch (Exception e) { result = null; App.LogException(e); } } return(result); }
public async Task <ObservableCollection <Event> > GetNextFutureEventListPageAsync(Event evento) { ObservableCollection <Event> result = new ObservableCollection <Event>(); if (evento != null) { try { IDocumentSnapshot documentSnapshotLast = await _firestore.GetCollection(nameof(Event)).GetDocument(evento.Id).GetDocumentAsync(); if (documentSnapshotLast != null) { IQuerySnapshot querySnapshot = await _firestore.GetCollection(nameof(Event)) .WhereGreaterThanOrEqualsTo(nameof(Event.StartDateTime), DateTime.Now) .OrderBy(nameof(Event.StartDateTime)) .StartAfter(documentSnapshotLast) .LimitTo(20) .GetDocumentsAsync(); foreach (IDocumentSnapshot documentSnapshot in querySnapshot.Documents) { if (documentSnapshot.Exists) { Event newEvent = documentSnapshot.ToObject <Event>(); result.Add(newEvent); } } } } catch (Exception e) { result = null; App.LogException(e); } } return(result); }
/// <summary> /// Initializes a new instance of the <see cref="QuerySnapshotProvider{T}"/> class. /// </summary> /// <param name="sourceQuery">The query to snapshot.</param> /// <param name="parent">The parent that created this.</param> public QuerySnapshotProvider(IQueryable sourceQuery, IQuerySnapshot parent) : base(sourceQuery) { Parent = parent; }