Example #1
0
 public MySyncUploadSaveCallback(NotesActivity notesActivity, List<ParseObject> parseItems, List<NoteScripture> dbNotes)
 {
     _notesActivity = notesActivity;
     _parseItems = parseItems;
     _dbNotes = dbNotes;
 }
Example #2
0
        public void SyncUserNotesToParse(NotesActivity notesActivity, List<NoteScripture> notes)
        {
            if (!ConnectedToNetwork(context))
            {
                return;
            }

            Parse.Initialize(context, "scBTJphDK8yVGGtNhcL9cYee89GbEKuRkygGYXKa", "wlXg6dWeJBCxD3uNbnoCTnnZlpSvvZWOdfyoeREZ");

            List<ParseObject> parseItems = new List<ParseObject>();
            List<NoteScripture> dbNotes = new List<NoteScripture>();

            foreach (NoteScripture note in notes)
            {
                ParseQuery query = new ParseQuery("Note");
                query.WhereEqualTo("objectId", note.NWTId);
                IEnumerable<ParseObject> existedObjects = query.Find();

                // Does not exist in Parse
                if (existedObjects.Count() == 0)
                {
                    ParseObject testObject = new ParseObject("Note");
                    testObject.Put("book", note.Book);
                    testObject.Put("bookName", note.Book);
                    testObject.Put("chapter", note.Chapter);
                    testObject.Put("name", ParseUser.CurrentUser.Username);
                    testObject.Put("title", note.NoteTitle);
                    testObject.Put("note", note.NoteBody);
                    testObject.Put("text", note.Scripture);
                    testObject.Put("verse", note.Verses);
                    testObject.Put("nwtId", note.NWTId);

                    parseItems.Add(testObject);
                    dbNotes.Add(note);
                }
                // Exists in Parse
                else if (existedObjects.Count() == 1)
                {
                    query.GetInBackground(note.NWTId, new MyGetCallback(note, "update"));
                }
            }

            ParseObject.SaveAllInBackground(parseItems, new MySyncUploadSaveCallback(notesActivity, parseItems, dbNotes));
        }
Example #3
0
 public MyFindCallback(NotesActivity notesActivity)
 {
     _notesActivity = notesActivity;
 }
Example #4
0
        public void SyncUserNotesFromParse(NotesActivity notesActivity)
        {
            if (!ConnectedToNetwork(context))
            {
                return;
            }

            Parse.Initialize(context, "scBTJphDK8yVGGtNhcL9cYee89GbEKuRkygGYXKa", "wlXg6dWeJBCxD3uNbnoCTnnZlpSvvZWOdfyoeREZ");

            ParseQuery query = new ParseQuery("Note");
            query.WhereEqualTo("name", ParseUser.CurrentUser.Username);
            query.FindInBackground(new MyFindCallback(notesActivity));
        }