CleanArchitecture | Clean Architecture Template for Blazor WebAssembly Built | Frontend Framework library
kandi X-RAY | CleanArchitecture Summary
kandi X-RAY | CleanArchitecture Summary
So, here is an in-depth video that takes you through the BlazorHero Project! Do Like & Subscribe to my Youtube channel! It would be great if you could leave behind your valuable feedback in the comments section of the Video. This helps me reach a much wider audience with time :).
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of CleanArchitecture
CleanArchitecture Key Features
CleanArchitecture Examples and Code Snippets
Community Discussions
Trending Discussions on CleanArchitecture
QUESTION
I am trying to implement an ASP.NET Core MVC web app similar to Jason Taylor's CleanArchitecture design. In the WebUi "layer" I try to implement an abstraction of an IIdentityService
in which I want to access the ClaimsPrincipal associated with the current HttpRequest
.
After some digging through the source code on github, I found that the Controller.User
property stems from ControllerBase.HttpContext? which is derived from ControllerContext which in turn is derived from ActionContext in which the HttpContext
property is defined as
ANSWER
Answered 2022-Feb-21 at 07:21After being hinted in the right direction by @JHBonarius in the comments, I found a documented case in the official documentation
Use HttpContext from custom componentsFor other framework and custom components that require access to HttpContext, the recommended approach is to register a dependency using the built-in Dependency Injection (DI) container. The DI container supplies the IHttpContextAccessor to any classes that declare it as a dependency in their constructors:
QUESTION
In the method GetNotificationCorrespondingToDomainEvent
in
https://github.com/jasontaylordev/CleanArchitecture/blob/main/src/Infrastructure/Services/DomainEventService.cs, it has the following method,
ANSWER
Answered 2022-Feb-12 at 18:50The difference is that
QUESTION
I have a project created using the clean architecture template.
If I want a domain event be raised when a new project is created, where do I add that?
If I have to raise an event whenever a new item be added to a project, I can accomplish that in the Project entity as shown here.
Similarly for MarkCompletion of a ToDoItem as done here.
But its not clear where do I put the code to raise an event when a new Project is created?
One option is doing something like the following in Create End Point here.
...ANSWER
Answered 2022-Jan-30 at 07:20When you need to raise a domain event on project creation I would create a factory method that publishes the event.
You can use a static method or implement a factory object.
QUESTION
For references: https://github.com/ardalis/CleanArchitecture
The BaseEntity model contains a List
. This list is being ignored in when doing EF Migrations.
ANSWER
Answered 2021-Dec-01 at 01:44It's a field, not a property, so it's ignored. EF only maps properties. Yes, since it's a field, it should probably be named _events
instead of Events
.
QUESTION
I am working on a .NET 5 targeted ASP.NET API where I need to access three different SQL databases.
I am using AutoFac as my DI (disclaimer: I am new to AutoFac and have only used the ASP.NET Core build in DI in the past).
I am also using the CleanArchitecture framework from Steve Smith (https://github.com/ardalis/CleanArchitecture)
I am using generic repositories, one for each DbContext (representing the 3 different databases).
I have the following code in my startup project's Startup.cs --> ConfigureContainer method;
...ANSWER
Answered 2021-Sep-16 at 17:10Autofac will give you the most recently registered instance type, which is why you're getting the last one. You can actually request (via DI) an IEnumerable>
in your endpoint class if you want, and Autofac should give you all of the registered instances for that type. That might help you in debugging, or if you want to use some strategy in the endpoint to select which one is the appropriate instance for a given request.
QUESTION
Unhandled exception rendering component:
Cannot provide a value for property
_accountService
on typeInventory_Management.Client.Pages.Authentication.Login
. There are no registered service of typeInventory_Management.Shared.Services.AccountService
.
AccountService.cs
...ANSWER
Answered 2021-Aug-17 at 14:37You need to register your concrete class in Startup class's ConfigureServices method. Try the following.
QUESTION
I using CleanArchitecture solution. I have Data layer where ApplicationDbContext and UnitOfWork are located :
...ANSWER
Answered 2021-Jun-13 at 12:31finally, I found my answers in this article https://snede.net/you-dont-need-a-idesigntimedbcontextfactory/
Create ApplicationDbContextFactory in Portal.Data project:
QUESTION
I am having trouble wiring up identity into Blazor server with ASP.NET Core identity. Specifically getting the correct logged in state in Blazor pages (while I am getting them from the Blazor pages).
I think it's related to some of the startup being initialized in another project - but not sure how to debug it or what the solution is to be able to get the logged in state correctly.
Reproduction steps and link to GH repo below as a POC.
Background
I'm porting over the clean-code project by JasonTaylor from Angular / ASP.NET Core to a Blazor server project with ASP.NET Core Identity.
Issue
The application runs up and I can browse the pages when I register I can see logged-in state in the identity-based default pages but in the Blazor pages that use the AuthorizeView
(e.g. LoginDisplay.razor
) it's not aware of being authorized.
Startup in the Blazor project:
...ANSWER
Answered 2021-Jun-10 at 08:10This was an issue with mixing IdentityServer and ASP.net identity.
By removing Microsoft.AspNetCore.ApiAuthorization.IdentityServer
and the use of base class from ApiAuthorizationDbContext
back to IdentityDbContext
resolved this.
QUESTION
What is the best way to call a SQL function / stored procedure when converting code to use the repository pattern? Specifically, I am interested in read/query capabilities.
Options
- Add an
ExecuteSqlQuery
toIRepository
- Add a new repository interface specific to the context (i.e.
ILocationRepository
) and add resource specific methods - Add a special "repository" for all the random stored procedures until they are all converted
- Don't. Just convert the stored procedures to code and place the logic in the service layer
Option #4 does seem to be the best long term solution, but it's also going to take a lot more time and I was hoping to push this until a future phase.
Which option (above or otherwise) would be "best"?
NOTE: my architecture is based on ardalis/CleanArchitecture using ardalis/Specification, though I'm open to all suggestions.
...ANSWER
Answered 2021-May-02 at 16:21Don't treat STORED PROCEDURES as 2nd order citizens. In general, avoid using them because they very often take away your domain code and hide it inside database, but sometimes due to performance reasons, they are your only choice. In this case, you should use option 2 and treat them same as some simple database fetch.
Option 1 is really bad because you will soon have tons of SQL in places you don't want (Application Service) and it will prevent portability to another storage media.
Option 3 is unnecessary, stored procedures are no worse than simple Entity Framework Core database access requests.
Option 4 is the reason why you cannot always avoid stored procedures. Sometimes trying to query stuff in application service/repositories will create very big performance issues. That's when, and only when, you should step in with stored procedures.
QUESTION
I'm getting this error:
Database operation expected to affect 1 row(s) but actually affected 0 row(s)
when adding a new element to the entity's collection.
Base classes in Domain
project:
ANSWER
Answered 2021-Apr-19 at 16:36The problem was that by generating my Id's manually, the new entity got the Modified
state, instead of Added
state. The fix was using the Fluent API's .ValueGeneratedNever()
method with the modelBuilder
.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install CleanArchitecture
Install the latest .NET 5 SDK
Install the latest DOTNET & EF CLI Tools by using this command dotnet tool install --global dotnet-ef
Install the latest version of Visual Studio IDE 2019 (v16.8 and above) 🚀
Open up Command Prompt and run dotnet new --install BlazorHero.CleanArchitecture to install the project template
Create a folder for your solution and cd into it (the template will use it as project name)
Run dotnet new BlazorHero.CleanArchitecture to create a new Solution with all the Awesomeness 🕶️ of BlazorHero 🦸
Install Docker on Windows via https://docs.docker.com/docker-for-windows/install/
Open up Powershell on Windows and run the following cd c:\ dotnet dev-certs https -ep $env:USERPROFILE\.aspnet\https\aspnetapp.pfx -p securePassword123 dotnet dev-certs https --trust Note - Make sure that you use the same password that has been configured in the docker-compose.yml file. By default, securePassword123 is configured.
5005 & 5006 are the ports setup to run blazorHero on Docker, so make sure that these ports are free. You could also change the ports in the docker-compose.yml and Server\Dockerfile files.
Now navigate back to the root of the BlazorHero Project on your local machine and run the following via terminal - docker-compose -f 'docker-compose.yml' up --build
This will start pulling MSSQL Server Image from Docker Hub if you don't already have this image. It's around 500+ Mbs of download.
Once that is done, dotnet SDKs and runtimes are downloaded, if not present already. That's almost 200+ more Mbs of download.
PS If you find any issues while Docker installs the nuget packages, it is most likely that your ssl certificates are not installed properly. Apart from that I also added the --disable-parallel in the Server\Dockerfileto ensure network issues don't pop-up. You can remove this option to speed up the build process.
That's almost everything. Once the containers are available, migrations are updated in the MSSQL DB, default data is seeded.
Browse to https://localhost:5005/ to use your version of BlazorHero !
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page