jreed-Aces / note-taker

0 stars 0 forks source link

Refactor data manipulation code into separate service class #25

Closed sweep-ai[bot] closed 1 year ago

sweep-ai[bot] commented 1 year ago

Description

This PR refactors the data manipulation portion of the Program.cs file into its own service class, NoteService, which implements the INoteService interface. The goal is to make the code more modular, reusable, and testable. The new service class is added to the Services folder.

Summary

Fixes #24.


To checkout this PR branch, run the following command in your terminal:

git checkout sweep/refactor-data-manipulation_1

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.

jreed-Aces commented 1 year ago

The Microsoft.Extensions.DependencyInjection needs to be included in the project.

sweep-ai[bot] commented 1 year ago

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

```
jreed-Aces commented 1 year ago

The ID should be detected in AddNote() and not used as a parameter.

sweep-ai[bot] commented 1 year ago

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.
jreed-Aces commented 1 year ago

the interface shouldn't have the id parameter anymore either for AddNote

sweep-ai[bot] commented 1 year ago

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.