Exemplo n.º 1
0
        public async Task <ActionResult <NoteBook> > CreateNoteBook(NoteBook noteBook)
        {
            noteBook.NoteLists = new List <NoteList>();
            _context.NoteBooks.Add(noteBook);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetNoteBooks), new { id = noteBook.Id }, noteBook));
        }
Exemplo n.º 2
0
        public async Task <ActionResult <NoteList> > CreateNoteListInBook(long noteBookId, NoteList noteList)
        {
            noteList.NoteBook = await _context.NoteBooks
                                .Include(nb => nb.NoteLists)
                                .FirstOrDefaultAsync(nb => nb.Id == noteBookId);

            noteList.Notes = new List <Note>();
            noteList.NoteBook.NoteLists.Add(noteList);
            _context.NoteLists.Add(noteList);

            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetNoteList", new { id = noteList.Id }, noteList));
        }
Exemplo n.º 3
0
        public async Task <ActionResult <Note> > CreateNoteInList(long noteListId, Note note)
        {
            note.NoteList = await _context.NoteLists
                            .Include(nl => nl.Notes)
                            .FirstOrDefaultAsync(nl => nl.Id == noteListId);

            note.Complete = false;
            note.NoteList.Notes.Add(note);
            _context.Notes.Add(note);

            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetNote", new { id = note.Id }, note));
        }
Exemplo n.º 4
0
        public async void HasRenamed(Notebook notebook)
        {
            if (notebook != null)
            {
                var notebookToedit = await context.Notebooks.Where(n => n.Id == notebook.Id).SingleAsync();;
                notebookToedit.Name = notebook.Name;
                context.Notebooks.AddOrUpdate(notebookToedit);
                await context.SaveChangesAsync();

                IsEditing = false;
                ReadNotebooks();
            }
        }