public async Task <User> Login(User tempUser) { try { var query = user.CreateDocumentQuery <User>(collectionLink, new FeedOptions { EnableCrossPartitionQuery = true, MaxItemCount = -1 }) .Where(user => user.Email == tempUser.Email && user.Password == tempUser.Password) .AsDocumentQuery(); Clients = new List <User>(); while (query.HasMoreResults) { Clients.AddRange(await query.ExecuteNextAsync <User>()); } if (Clients.Count > 1 || Clients.Count == 0) { return(null); } } catch (Exception e) { Console.Error.WriteLine(@"Error{0}", e.Message); return(null); } return(Clients[0]); }
public async Task <User> InsertUser(User NewUser) { try { var result = await user.CreateDocumentAsync(collectionLink, NewUser); NewUser.Id = result.Resource.Id; users.Add(NewUser); } catch (Exception e) { Console.Error.WriteLine(@"ERROR {0}", e.Message); } return(NewUser); }