ExerciseTracker.TwilightSaw#59
Open
TwilightSaw wants to merge 4 commits intothe-csharp-academy:mainfrom
Open
Conversation
Start of the project, added based files and functionalities.
Added various functionalities, fixes, validations and others.
Added another repository version
Finished the project, completely implemented second repository to use, added image folder and README
chrisjamiecarter
approved these changes
Dec 9, 2024
chrisjamiecarter
left a comment
There was a problem hiding this comment.
Hey @TwilightSaw 👋,
Excellent work on your ExerciseTracker project submission 🎉!
I have performed a peer review and have added some praise and suggestions as bespoke comments.
I will go ahead and mark as approved, keep up the excellent work on the next projects! 😊
Best regards,
@chrisjamiecarter 👍
| .AddJsonFile("appsettings.json") | ||
| .Build(); | ||
|
|
||
| new Menu(new ExerciseController(new ExerciseService(new ExerciseRepository<Exercise>(context), |
There was a problem hiding this comment.
🟠 Optimizing for a Dependency Injection Framework
💡 In a modern DI setup, you would typically register services with the DI container in a ConfigureServices method or equivalent during application startup. For example:
services.AddDbContext<AppDbContext>(options =>
options.UseSqlServer(configuration.GetConnectionString("DefaultConnection")));
services.AddScoped<IExerciseRepository<Exercise>, ExerciseRepository<Exercise>>();
services.AddScoped<IExerciseService, ExerciseService>();
services.AddScoped<IExerciseDapperRepository<Exercise>, ExerciseDapperRepository<Exercise>>();
services.AddScoped<IExerciseController, ExerciseController>();
Then resolve the top-level service (Menu) through the DI container:
using var scope = app.Services.CreateScope();
var menu = scope.ServiceProvider.GetRequiredService<Menu>();
menu.AddMenu();
This approach:
- Removes the need for manual dependency management.
- Promotes scalability and testability.
- Simplifies code by letting the DI container handle lifecycle management.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.