public IActionResult CreateTodoNote(Guid todoId, [FromBody] TodoNoteCreateDto todoNoteCreate) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (!_todoRepository.TodoExists(todoId)) { return(NotFound("Todo Id does not exist")); } var todoNoteEntity = _mapper.Map <TodoNote>(todoNoteCreate); _todoRepository.AddNoteToTodo(todoId, todoNoteEntity); _todoRepository.Save(); var noteDtoToReturn = _mapper.Map <TodoNoteDto>(todoNoteEntity); return(CreatedAtRoute("GetTodoNote", new { todoId, noteId = noteDtoToReturn.Id }, noteDtoToReturn)); }