Beispiel #1
0
        public async Task DeleteNote(NoteGetModel note)
        {
            try {
                await NoteService.Delete(note.Id);

                Notes.Remove(note);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                await Application.Current.MainPage.DisplayAlert("Error", "Note already deleted.", "OK");
            }
        }
Beispiel #2
0
        public static NoteGetModel GetAll(string user_id)
        {
            NoteDbContext db     = new NoteDbContext();
            var           notes  = db.Notes.Where(x => x.UserId == user_id).ToArray();
            NoteGetModel  result = new NoteGetModel();

            result.NoteName = new string[notes.Length];
            result.NoteText = new string[notes.Length];
            if (notes.Length > 0)
            {
                for (int i = 0; i < notes.Length; i++)
                {
                    result.NoteName[i] = notes[i].NoteName;
                    result.NoteText[i] = notes[i].NoteText;
                }
            }
            return(result);
        }
Beispiel #3
0
        public async Task <List <NotePushedDataModel> > Push(List <NotePushModel> model, int userId)
        {
            try {
                var IPushedThis = new List <NotePushedDataModel>();
                foreach (var m in model)
                {
                    if (m.Id == null)
                    {
                        NoteGetModel item = null;
                        item = await this.Add(new NoteInsertModel
                        {
                            Modified = m.Modified,
                            Text     = m.Text,
                            Title    = m.Title,
                            Version  = m.Version
                        }, userId);

                        IPushedThis.Add(new NotePushedDataModel
                        {
                            DatabaseExternalId = item.Id,
                            DatabaseLocalId    = m.LocalId
                        });
                    }
                    else
                    {
                        await this.Update(new NoteUpdateModel
                        {
                            Id       = (int)m.Id,
                            Modified = m.Modified,
                            Text     = m.Text,
                            Title    = m.Title,
                            Version  = (int)m.Version
                        }, userId);
                    }
                }
                return(IPushedThis);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }