Skip to content

Commit f818c1e

Browse files
committed
Implement /categories/:id/notes/:id
1 parent 7d71e0d commit f818c1e

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

src/Core/Application/Services/INoteTaker.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ public interface INoteTaker
2424
CategoryDto TakeCategorizedNote(Guid categoryId, NewNoteMessage newNoteMessage);
2525
CategoryDto RemoveCategorizedNote(Guid categoryId, Guid noteId);
2626
IList<NoteDto> ListCategorizedNotes(Guid categoryId);
27+
NoteDto ReadCategorizedNote(Guid categoryId, Guid noteId);
2728
}
2829
}

src/Infrastructure.Server/NoteTaker.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,13 @@ public IList<NoteDto> ListCategorizedNotes(Guid categoryId)
177177
return _mapper.Map<IList<NoteDto>>(category.Notes);
178178
}
179179

180+
public NoteDto ReadCategorizedNote(Guid categoryId, Guid noteId)
181+
{
182+
var category = GetCategory(categoryId);
183+
var note = category.RevealNote(noteId);
184+
return _mapper.Map<NoteDto>(note);
185+
}
186+
180187
private ICategory GetDefaultCategory()
181188
{
182189
var defaultCategoryName = "default";

src/Infrastructure.WebApi/Controllers/v1/CategoriesController.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,5 +113,22 @@ public IActionResult GetNotesFromCategory(Guid id)
113113
var noteDtos =_noteTaker.ListCategorizedNotes(id);
114114
return Ok(noteDtos);
115115
}
116+
117+
/// <summary>
118+
/// Get all notes from the given category
119+
/// </summary>
120+
/// <param name="id">Category Identifier.</param>
121+
/// <param name="noteId">Note Identifier.</param>
122+
/// <response code="200">Note found and returned</response>
123+
// GET api/v1/categories/{id}/notes/{id}
124+
125+
[HttpGet, Route("{id:guid}/notes/{noteId:guid}")]
126+
[ProducesResponseType(typeof(NoteDto), 200)]
127+
[ProducesResponseType(typeof(BadRequestResult), 400)]
128+
public IActionResult GetNoteFromCategory(Guid id, Guid noteId)
129+
{
130+
var noteDto =_noteTaker.ReadCategorizedNote(id, noteId);
131+
return Ok(noteDto);
132+
}
116133
}
117134
}

0 commit comments

Comments
 (0)