public async Task <NoteListDTO> CreateNoteItemAsync(string noteId, CreateNoteItemDTO dto) { var noteList = await _repository.GetItemAsync(noteId); if (noteList == null) { throw new NotFoundException("Note list not found."); } var item = _mapper.Map <NoteItem>(dto); item.Status = NoteItemStatus.Pending; if (noteList.Items == null) { noteList.Items = new List <NoteItem>(); } noteList.Items.Add(item); var updatedList = await _repository.UpdateItemAsync(noteId, noteList); return(_mapper.Map <NoteListDTO>(updatedList)); }
public async Task <ActionResult <NoteListDTO> > PostItemAsync(string noteId, [FromBody] CreateNoteItemDTO dto) { var note = await _noteService.CreateNoteItemAsync(noteId, dto); return(Ok(note)); }