public async Task <NoteListDTO> UpdateNoteItemAsync(string noteId, string itemId, UpdateNoteItemDTO dto) { var noteList = await _repository.GetItemAsync(noteId); if (noteList == null) { throw new NotFoundException("Note list not found."); } var item = noteList.Items.Where(o => o.Id == itemId).FirstOrDefault(); if (item == null) { throw new NotFoundException("Note item not found."); } _mapper.Map(dto, item); var updatedList = await _repository.UpdateItemAsync(noteId, noteList); return(_mapper.Map <NoteListDTO>(updatedList)); }
public async Task <ActionResult <NoteListDTO> > PutItemAsync(string noteId, string itemId, [FromBody] UpdateNoteItemDTO dto) { var note = await _noteService.UpdateNoteItemAsync(noteId, itemId, dto); return(Ok(note)); }