Closed sweep-ai[bot] closed 1 year ago
The Microsoft.Extensions.DependencyInjection needs to be included in the project.
The Microsoft.Extensions.DependencyInjection needs to be included in the project.
Hi @jreed-Aces,
I decided to make the following changes:
File Path | Proposed Changes |
---|---|
note-taker.csproj |
Modify note-taker.csproj with contents: • Add the following line to the ItemGroup section: ```xml ``` |
The ID should be detected in AddNote() and not used as a parameter.
The ID should be detected in AddNote() and not used as a parameter.
Hi @jreed-Aces,
I decided to make the following changes:
File Path | Proposed Changes |
---|---|
Services/NoteService.cs |
Modify Services/NoteService.cs with contents: • In the NoteService class, modify the AddNote method to remove the id parameter.• Inside the AddNote method, retrieve the list of notes from the JSON file and check if it is empty or not.• If the list is not empty, find the highest id from the existing notes and increment it by 1 to assign a new id to the added note.• Add the new note to the list of notes. • Serialize the updated list of notes to JSON and write it back to the file. |
the interface shouldn't have the id parameter anymore either for AddNote
the interface shouldn't have the id parameter anymore either for AddNote
Hi @jreed-Aces,
I decided to make the following changes:
File Path | Proposed Changes |
---|---|
Services/INoteService.cs |
Modify Services/INoteService.cs with contents: • Remove the id parameter from the AddNote method in the INoteService interface. |
Description
This PR refactors the data manipulation portion of the Program.cs file into its own service class,
NoteService
, which implements theINoteService
interface. The goal is to make the code more modular, reusable, and testable. The new service class is added to theServices
folder.Summary
INoteService
in theServices
folder, which defines the methods for adding and printing notes.NoteService
class in theServices
folder, which implements theINoteService
interface. The data manipulation code from theaddCommand
andprintCommand
handlers inProgram.cs
is moved to theAddNote
andPrintNotes
methods inNoteService.cs
respectively.Program.cs
file to use theNoteService
class via dependency injection. The dependency injection container is set up to useNoteService
whenever an instance ofINoteService
is requested.addCommand
andprintCommand
handlers inProgram.cs
to use theAddNote
andPrintNotes
methods provided by theINoteService
interface.Fixes #24.
To checkout this PR branch, run the following command in your terminal:
To get Sweep to edit this pull request, leave a comment below or in the code. Leaving a comment in the code will only modify the file but commenting below can change the entire PR.