Example #1
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            bool retVal = false;

            if (value != null)
            {
                ConversationModel conversation = value as ConversationModel;
                if (conversation.converseeID.Equals(dataClass.loggedInUser.uid))
                {
                    retVal = true;
                }
            }


            return(retVal);
        }
Example #2
0
        public async void Send_Message(object sender, EventArgs e)
        {
            string            ID           = IDGenerator.generateID();
            var               result       = new List <ConversationModel>();
            ConversationModel conversation = new ConversationModel()
            {
                id          = ID,
                converseeID = dataClass.loggedInUser.uid,
                message     = editor.Text,
                created_at  = DateTime.UtcNow
            };
            await CrossCloudFirestore.Current
            .Instance
            .GetCollection("contacts")
            .GetDocument(newCon.id)
            .GetCollection("conversations")
            .GetDocument(ID)
            .SetDataAsync(conversation);

            editor.Text = string.Empty;
            var documents3 = await CrossCloudFirestore.Current
                             .Instance
                             .GetCollection("contacts")
                             .GetDocument(newCon.id)
                             .GetCollection("conversations")
                             .OrderBy("created_at", false)
                             .GetDocumentsAsync();

            foreach (var documentChange in documents3.DocumentChanges)
            {
                var json = JsonConvert.SerializeObject(documentChange.Document.Data);
                var obj  = JsonConvert.DeserializeObject <ConversationModel>(json);

                result.Add(obj);
            }
            conversationListview.ItemsSource = result;
        }