Example #1
0
        public async Task <Note> GetNoteByIdAsync(string id)
        {
            IEnumerable <Note> localNotes = _noteMethod.GetAllNotesFromFile(_userId);

            if (await InternetConnection.IsInternetConnectionAvailable())
            {
                string             token       = await new AuthenticationToken(ConnectionApi.HttpClient).PostAuthRecordAsync(_authenticationRecord);
                IEnumerable <Note> remoteNotes = await _noteMethod.GetAllNotesFromDatabase(token);

                UpdateNoteDatabase(remoteNotes, localNotes, token);
            }
            return(_noteMethod.GetNoteFromFile(id, _userId));
        }
Example #2
0
        public async Task AddNoteAsync(Note note)
        {
            _noteMethod.AddNoteToFile(note);
            IEnumerable <Note> localNotes = _noteMethod.GetAllNotesFromFile(_userId);

            if (await InternetConnection.IsInternetConnectionAvailable())
            {
                string token = await new AuthenticationToken(ConnectionApi.HttpClient).PostAuthRecordAsync(_authenticationRecord);
                await _noteMethod.AddNoteToDatabase(note, token);

                IEnumerable <Note> remoteNotes = await _noteMethod.GetAllNotesFromDatabase(token);

                UpdateNoteDatabase(remoteNotes, localNotes, token);
            }
        }