how to implement Clean architecture skeleton step by step | c# clean architecture

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
let's get start Demo First of clean architecture skeleton and here uh I just create a two feature in this clean architecture using net core pic as a Blog uh blog features and author features right and also if I see over here so this is our clean architecture es skeleton which we will have to create it so we have know core we have an infrastructure and we have a presentation layer and then we have the unit test cases projects right so this is actually complete skeleton we have to create it over here and along with this feature so let me quickly see how the feature is working like for example I have one feature of the blogs which will returning on the blogs so let me try to get so now see I have returning on the blocks using that you know nice and you know block section and along with this whatever that response right it is a true false and all so those are things we have to just convering our dto so this is also be using imapper and here just trying to create a user can create a new blogs over here for example uh shop right and then shop is a powerful language right shop is uh powerful language right and then once you execute see it is just created whatever new Blog has been created along with their response and if you want to check again whatever that uh newly we have to create it see it just created new blogs along with the response and even we have another features uh which will we can return that blogs for example whatever newly block has been created uh we can get by the ID like six ID they will created right so if I put that six and then execute we are returning the data right and then we have some you know validation stuff also over there for example if you you go down over here right so suppose example I just trying to uh update something right so for example that I want to update something n number which is not present over here and once I try to execute now see it is also we have covered in this Cen architecture skeleton that validation we use the fluent UI uh fluent API to You Know cover our validations so that also we have to add it in this our skeleton and then if I just correct one it should be update right so let me add this guy and then for example uh C to C 12 right so C 12 and then C C 12 and then it then once you try to execute now it is returning back to success as well as once I uh before even I try so let me check it is properly update or not uh let me get again now see is properly update with that near new data and as well as let me try to delete so we have our delete mechanism as well so let me try to delete this guy so see now delete also successful with this status code and success we can check it over here one more time uh with this get by ID block so now see there is a no blocks for this particular things and also uh we can return and check like all blocks is there any blocks exist or not which one we just recently added right there is no blocks so this is one feature now we uh we have also uh create another feature in this template that is actually author so this two feature we have to create this is a normal genic repositive pattern we have Ed but yeah I just create this another feature because I have added in this skeleton and another uh what can say uh another extension extension repository mechanism so so that you can use it so for example suppose I want to check something uh if I execute right it is validation over here and suppose I just pass something right that like so see it is returning a data using that extended extend uh repository pattern right so that also we will handle in this template skeleton clean architecture and then finally you can just edit your uh new author for example example uh Kik Kumar right and then whatever my Gmail right okay Kumar atate something gmail.com then execute so here uh once I just try to this guy so let me check this guy so now see whatever newly we have added that also added but this time this feature actually we have trying to use our extendable repository so that we have to cover so that's all for the demo demo now moving start for implementation so before implementation I'm especially recommend just go to my channel which is actually net real world example and here go to my playlist section and go to that know Master Clean architecture series actually uh we in this clean architecture series with using cqrs and Med we actually cover in know many session like almost 13 17 session so here I just deeply explain everything step by step so that you have to first check out because I'm not going to explain again I just focus on the implementation so that's why I'm a recommendation please watch on this session right and then uh move it forward to this session so now uh go to the implementation so first what you have to new what you have to do that uh go to that Visual Studio open that visual studio and here I'll just create a new project right go to that new project and and uh let me choose a blank solution right so we will do a from the scratch and this is called a solution right so solution let me look for the solution and here that solution template because first we have to record the template right and in this template we have to we have to create our folder structure and you know a project structure uh first then we will try to implementation and we will do actually end to end flow everything so let me create a blank solution so here the blank solution and we can put our solution name over here so what would be the full solution name like that suppose whatever your project right so my project belong to is a blog or suppose my project belong to as a product right or my product belong to you know something else like you know hotel management system so you can just use the hotel management system and that what you're trying to do over here in this uh template I'm just trying to use API right or if you want to try to something else right so whatever you want to use so you can just mention your things right so I just trying to use API so I will use API and what is our project name my project name is a block right so that's way actually we can create or we can keep it and also it is a important part in this location part right so where you have to set that location so let me use my location I will put it the Mr D you know in this location and along this location what would be my you know uh you know folder name and all right so my uh folder name would be over here for example uh it is a clean architecture right so clean you know architecture right clean architecture and then it is a skeleton so let me create a skeleton skeleton right and then it is a demo so this is my for uh know my folder struction name and then here what I will do in this folder what I will do I have to just create another folder that is called SRC right because everything will be stored in this SRC and that's it right so in this SRC we have to create a solution like that and then create once you create now see this is a blank solution it will create right and I want to see the folder structure whatever we're trying to do that is a perfectly fine or not open that open file folder Explorer here and go back to here now see it is perfectly uh it's perfectly creating what we want like first we have to create now inside this project we have to create a one folder that is a green architecture skeleton demo and inside this you know Source folder and many things actually we have to do over here like for example as of now we have to create know SRC right so in later on we if you want to something else so we can keep it and then here this is my API folder which we create right so in this API folder we have that solution and this is this is actually root folder where we create all other know layers as well like domain infrastructure and applications everything we have to keep it in this location and in this uh folder here see this is API and then other things also we have to create like for example DB script and other functions and things also we can create it over here right so that is way we have to create it now go move it to back over here now we have to do actually some uh we have to create you know some folder over here so let me create first like whatever C architecture actually supported that folder so first actually we have to create that core right because this is a main main layer uh which will contain you know application and that entities right on domain entities so once you created core right so then create another one uh let me create that one let me create a name and infrast structure folder right so here whatever in outer layer we will whatever implementation actually concrete implementation we have to keep in this infrastructure layer right and then what is my next layer that is a presentation layer which will keep all our UI Stu right so let me create that folder and keep it that presentation layer here we will keep our UI you know UI layer like for example API abbab applications and other whatever UI which will interact our you know core and infrastructure right so that we will keep over here and then finally the last last layer um will we have to create for the test project right so whatever unit test cases actually we have to reord we have to keep inside this test projects so this is actually our clean architecture follow this uh folder structure like core infrastructure presentations and test right and basically uh we have to create one by one everything we have to implement so first we have to create an project structure so first let me add here like core one and here use that new project and look in a class Library let me add as a class Library so using that net uh net and net standard one use this guy and next and here what I have to do I just create a you know the name let me create a name and here again you can just use that you know whatever project name right suppose blog and then your domain name uh whatever Library name you can keep it like that but yeah I will use only just project name as a domain right and then also make sure it is a you know as a current directory right which we have to reord so use that current directory and then next so also use that whatever framework you want so as of now I will use the net 8 now my first actually library has been created inside it code layer so that is domain right and also uh we have a sample one so let let me remove this guy we don't require this guy we will Implement from the scratch and then another one is you know uh that application right so let me call that applications let me create actually applications let me add new project choose again that class library next use that here make sure your per current locations add create now our application layer also has been created right so let let me close and remove that guy so now core structure has been done right core library is completed now create it for that infrastructure right so go to that here let me create you know uh one project for the infrastructure right click on that folder go to add new project and choose class Library again and class library next use that infrastructure and choose that locations next use the framework and that's it and then again again we have to remove that extra class sample class we have to remove and then infrastructure also uh has been created right now we have to create for presentation uh layer right so let me create a one API inside as of now I will use API but yeah in upcoming session we'll Implement everything like for example web application bler application and MBC one rer applications and so on so right so let me create a uh web application use that web application template net core web API use here like web API right and yeah web API and choose that current location over here and then next and uh choose whatever you know configuration you required you can just choose it so as of now I'll just use that you know default things and accept that https so create that and now our API also has been created but yeah as of now we have not interacted anything yeah that is fine and then finally we have to just create a unit test case project so go to that new project and look for that X unit test cases right there's n unit also whatever things you want you can just use it but I will use that over here x unit test cases and here whatever you know unit test cases project you want to create you can just create like for example I want to create a application one right so application. unit test right so it is for application unit test so you can just create a application unit test like that and also if you want to create some infrastructure one so you can just create a infrastructure one right so like that and also if you want to create an API one so you can just use that API dot b API do unit test so like that you can just create you know things but yeah in this session will not using this guy right implementation of unit test cases that we'll be do in our upcoming another session right so now is pretty much good for our you know uh folder structure and know project structure of that clean architecture so this is actually uh required of the clean architecture of uh which we have to try to implement right so now now second step is now we have to implement one by one right so before implement mentation and we have to require actually some reference to each other actually the domain actually dependent the applications and application also is a uh infrastructure actually dependent on the applications right and also BPI actually know some not directly dependent but yeah indirectly dependency actually required for this application and and domain uh application and infrastructure for this API so this is actually way actually working the clean architecture right so now now let me start from that here so first of all I'll just create a you know entity folder over here so let me create that entity so it will be create a entity and also let me create another folder which will be maintain our settings in in our upcoming setting but yeah as of now we don't record any settings but yeah I'll just keep it for that as a template perspective so here we can keep in domains entities and settings right so let me create first my entities so whatever my entities over here so my first entity would be our blogs right which will be trying to over here we trying to two features right so first feature would be over your blogs and let me add this guy now what I can do simply I add some property inside that so this is my property and let me make it public right so this is one entity and now I have to I just show as a demo there's a two feature we have to try to implement what is the one is blog and second is author so let me create that one also so that we can complete uh the domain entities domain layer so let me create that guy also so create a sky author and here make it public again and use uh whatever your property is on this entity you can just use it right so this is entity uh for the author so this is domain one which is completed and there's a no dependency also domain because it's a Centric uh Centric driven approach so it will keep on Centric as a domain layer which will actually dependent an application layer and all right so this is done now moving back to our application layer and in application layer we have to do many many things over here actually application layer actually keep that application business rules and business logic over there right so what I can do right click on that add one a folder which is called over here in interface or contract right whatever things you want you can just use it but I will use that interface right so we can keep it our interface which will abstraction that we can use in our our presentation layer so we have to use that inter interface right and in this interface uh we have to create you know few things let me create that one first uh so let me create a new item let me create an interface choose that interface template and here I will use you know one generic repository right so let me create that I repository and here let me add and in this generic repository actually we have to use for that uh actually we have to use some common functionality right like add update insert delete right so that's why we have to create a generic reposit so that we can use these things for the all over the place in our applications so let me use this guy and also if you new for gentic depository go to my channel I am just I just created you know there's a few session for the genos in our net core web API and see this is just created a generic way right so that it it can be accept that all that entities which is a generic like for example if I want to use author if I want to use use that you know blog if I want to use the post anything you can just pass and you can just use their functionality and also what I will do I have to just create an F you method which we have to require to use for the all that um entities right so first is gety all uh method then second one is a get y ID add a syns update and delete right this is a common method actually so that is done right repository U has been created with generic repository and then uh later on we'll have to create a more over here but yeah as of now we'll keep it over there uh first we have to use implement this guy and then we have to come back to use the extendable repository so that we can keep it later so that is done now we have to create another folder that is called add new folder and here we'll use that features right so whatever features in your applications right so that you can use in this feature folders let me add this feature and in this features okay let me add completely feature right features right so inside this feature what I will do let me create another folder suppose whatever feature do do you have in your application for example I have uh two feature right right now right for one is blog and then another one is for example author right because as of now I have two so I can just create a blog and author and later on if you want to your your feature so you can add it to your feature as well so if in this blog uh features what I am trying to do we have to do in sqs pattern right this is a very important things uh to clean architecture that is a separation and consent things right so what I can do simply I just create a here so in this feature two type of things we have to separate of using the sqs pattern so that is actually for is first is a commands right and then second one is your uh queries so let me create another one uh queries so q u e r i s queries right so let me add that queries and like that actually it is support a sqs pattern which will actually whatever command like our your uh you know DML statement right so that will come will keep it in inside this commands and whatever you know read operations right like get by ID or get alls information so that we'll keep it that queries so if you don't know cqs pattern all please watch my previous session right which we already I covered everything uh related to sqs thing so please go to that so yeah as of now this is fine like I have just created this guy and this author one also we covered in later later in this series also but yeah let me Focus first this first Ser first feature block feature right and here we have to try to implement something but as of now uh I'll just keep it uh empty right because we have to do first actually we have to implement something over here then we can use it over here right so what I can do now let me create another things Now features also completed now uh we have to require some extension for that particular layers like like for example whatever dependencies over here that we have to register and resolve right so for that actually we can do we can create a separate folder that is called extension extensions and here I have to just create a one extension method that is called so application dependency injection registration so let me create that class and this could be you know public static right and here what I can do I have actually required some depend uh some package actually so now moving start uh to add our packages inside whatever packages we required we have to add it in this application layer right so let me add them package go to that manage package here browser and here my first package would be required over here you know uh some extensions dependent is right so let me let me let me search for that Microsoft yeah Microsoft extension dependencies right so this package actually be required and this is that package and once I install this package let me install that apply that now this is install this is my first package now second package would be our login things right so we required also login if you want to implement something login you can use that login over here so let me add that login package as well so this is that login package extension abstraction so install that guy so this also done now my third package would be in your mediator R right because we have to uh we have to we don't have a direct dependency of application layer to API layer right so that we have to do using that mediator R right so that we have to add some package so let me look for that package that is called mediator erer and this is that package name and install whatever latest version I have to use that guy apply so now mediator are also there now actually uh now another package be required which will be convert to entity D dto and D to entity right so that me add that package as well that is called automapper so I will use for the auto maper but yeah there's a many package actually do the same things but yeah this is a fine for us so I will use that auto maper right and then finally we have to reord some validation stuff right so whatever UI send the request they proper validate in this our application layer if it is Success that fored to that further but if it is not then we have to validate right so for that we have to use some package like that is called a fluent API so I will use that fluent API validations so I I use this guy and install that so these are package actually required if I if I show you in a in a here see these are package actually required in our application layer so this is important first let me add those packages over here and then further start to implementation so let me save it now go back to our application dependencies over here let me create over here one static uh know extension method right so create a public public uh static and use that I I I service service collections here and then use uh whatever method name you want to use so I'll just create this extension method name over here and then what I can do I have to use that extension of that I service collection and then we have to close this method first right and simply we have to return to this service right so like that actually we have to create our extension method and whatever dependency we have to we have to add our dependencies over here right dependencies so whatever dependency we have to keep it over here so my first dependency is over here which will I will uh resolve the dependencies which is an auto maper so let me resolve the dependency of the auto maper services dot add Auto maper auto mapper and here I have to record you know uh assemblies so whatever assembly assembl is here so that I have to just resolve like get by execute this method right like this way we have to for the auto maper assemblies right we have we don't worry about to you know you know one one by one assembly so that's why I using this method so that whatever uh whole assemblies in this our application project right so they will resolve together so that is one now second one is we have to resolve over here that mediator R right so again use that add mediator extension method this guy and then here I will use uh one delegate function and use that M do you know registered uh registered services from assemblies so register services from assembly right so this guy I have to use and then we have to edit over here and then inside that what I can do again I have to use this guy right so that I have to register all that assemblies again in the auto as well we have to don't declare one by one so like that these two things actually we have required for as of now but yeah in upcoming uh implementation if you record something else so we will do and take care in this here right so this is done right so this extension also done covered we have covered now we have covered like extension feature interface now we have to require one more folder over here that is called let me create that folder what is that folder name that is actually profile so let me add one profiles right profiles folder so here whatever conversion actually we required right so we have to add one profile uh folder we will cover everything for inside this profile uh mapping profile right so let me add uh one class over here that is called a mapping profile let me choose the name add and now we have to create it over here let me create a make it public right and then we have to inherit you know our profile uh profile uh autom maper class see this is auto which is coming Auto maper we have to inherit and then create a Constructor right and in this inside this Constructor we can use and you know map our things over here but yeah uh as of now we don't have any map things but yeah we just have to create that folder structure and all so that's why we have to keep it so required required mapping here right so let me keep it as like that that is also done now profile also has been done now finally we have to reord some response and all right which is a common thing so let me create that also uh so that uh we can create folder and create a response response folder so whatever response you want you can just create over here I'll just create a one Bas response which will use on our complete applications right so let me create That Base response over here and in this base response let me Implement some base response so that I can use every request as every response so first I have to just create a few property over here so my first property would be a success which is contain a Boolean right like that now we require another success message and the validation this is a common things right so every response we have to reord these three Fields right so that's why we have to create a base response so that I can use it and then we can manipulate something and based on the Constructor and parameter Constructor so let me create a Constructor over here first is you know our base Constructor right and here uh here we just said okay by default it should be always a true whatever response it should be always a true then let me create another parameter one parameter Constructor if somebody pass you know any message so that also we can handle over here so in here if somebody pass us some message whatever message then what we can try to do over here so let me set a message in this property and success would be by default is true right and then just create another one over here which will accept you know two parameter for example first is this and then second one also is a message uh yeah success message success uh flag if it is true or false So based on this flag so we can set it over here right and then whatever message let Set it over here so like that you can just use it right so this is a common base uh base response so now we have all almost covered everything like for the structure perspective so now this is actually structure uh we have to do that but yeah implementation future future implementation is still pending which will cover once is start to our infrastructure because it is a something required first implementation over here then we have to require to that right so so now application is done right so now two things I have just covered first is like you know our domain and then our applications now mov it to next for the infrastructure right and uh yeah move it back to infrastructure so before infrastructure moving what I have to do let me add the reference whatever the reference actually be required suppose this domain entity right so this domain entity required this application uh dependencies right so let me add the dependency right click on the dependencies go to here add the dependencies of the domain layer on this application layer right so let me add this guy right so once is ADD application decy done then what I need to do go to that uh infrastructure layer right and here let me create uh here some folder for example my first folder uh would be our you know data right so uh SE data and other things actually we have to require so first I'll just create create one repository um repository folder which will actually we have to we will Implement our concrete implementation right so let me add that repository okay just create a first year folder that is called a repository right here we will Implement all that our implementations right this is outer layer so that's why we have to keep it over here and then first uh let me create uh one repository which we have to already created right here in application layer uh there's a concrete over here that I repository right so that we have to implement over here so let me create that guy uh create a class over here right and here let me create uh you can use that base repository and all right whatever use that name you can use it but yeah reposit I will keep it at the repository here and then what I'm trying to do I have to just create this reposit Tre and make it an a generic first like this is a generic way and then uh inherit that uh I repository right which is not available as of now because we required some reference for the here right so let me add first reference also right click on the dependency add the reference and just add your application layer because application have that things right also this will be contain actually application and domain but yeah as of now it's fine fine because application also contain the domain layer right so we don't require that so we can keep it that application and this is done and then uh let me add that uh I repository which is coming application interface and just added this guy and let me start to implementation so Implement all the interface so now see all the Imp interface actually by default implemented over here right so this is the done and also we will implement but as of now I just keep it uh empty everything because we record you know some DV context and all so first we have to record some DV context created then we have to come back and Implement you know all the method right so first let me create a Deb context here so right click on that uh that folder and create a new class that is called our know DB context class so let me add the D context class over here so now before implementation the DB context class actually we required some packages so let me uh bring back that all the packages first right so right click on that project and go to again that new get package and look for that first package is Microsoft Entity framework core right because as of now I be using that EF core so I will use that but yeah in upcoming session we'll use on different different data provider right so as of now I will use this guy so use that installed apply accept so this is my first package right and then another package is required that is a be using a SQL Server as well right so that is the data provider so let me use that SQL Server so whatever you know provider you want to use you can use it but as of now I will use that SQL server and apply accept right so this is also done now second one actually we required some design EF Core Design package so let me add that guy so this is that you know Microsoft framework. design let me add this guy also which is actually helps to you know our migration and all we have to cover these things and last things we have to record the tools entity Frameworks tools so this four package actually important if you're trying to EF core the this four package actually required so let me install this guy and apply accept so now this is done and then one last things actually we have to record here this package so that is called extension hosting abstraction actually we have to trying to do some uh uh migration automatically so that's why we have to reord this guy because we have to create one extension method which will require this hosting uh abstraction right so that's why we have to use but don't worry I will tell you we are actually required so let me install first so that we don't require any packages requ in later so that is also done now I'll show you what are the package actually we have to install now see these are packages actually we have to install uh this is that Microsoft Entity framework design and then SQL Server wef core and then tools and then this guy right so these are packages actually requir so once it's done now go back to here uh to that block context here and here let me first import or just inherit uh DB context let me add DB context which is bring actually your name uh Microsoft Entity framework right and in here what I'm to create a Constructor and in this Constructor uh I have to create uh this parameter like DV context options and in here we have to passing our whatever D context right and just create options right and here we have to call that base and pass it to our options right so like that we have to just configur our you know D context class and then once it's done now we have to set some uh some D set right so which we have already created and also we have add the reference so let me add this guy right so we have just create a blog DB set as well as we have to we have to create some author DB set right so let me create that guy also so now uh author and DB actually DB set has been created and one last thing actually we have to do over here in this DB context that is called just me call the overload overwrite function and on on model creation so this is a configuration part right whatever you know entities if you want to configure like it is a one to many relationship and one to one relationship Etc so that we can cover inside this model creation right so that's I have just created like that uh we have to just create a DB context now moving back to your repositories which we have to create a repository right so here uh we have to just create a Constructor and inject your DB context class right and injected and then we are ready to go to use right so now we have to addit our injected our DB context class and now we have to start to our implementation because uh this implementation we require the DB context whatever DB set we have we have to use and we we can do that over here right so now start our DB context implementation uh no our uh generic repository implementation over here concrete implementation so so first I have to just Implement you know uh that get all method right so let me bring back over here and take it from the start so that I can uh process by order right so let me start from that get y right so what I can do first of all let me Implement here and let me add a weight right using a weight and use that your DV context class right and in this DB context class let me use the set method and then T and then here and Dot right and Dot whatever your know to list right it is returning to list to list async method and just assign and that's it and then finally we have to store something over here and then return or you can just directly you can return it right so like that actually we can Implement get by uh get by blocks so we actually already covered many many we are actually for the generic repository things so I'm not going to details but yeah this is a way actually you can get it so like that actually we have to implement all other things like for example I will just Implement get by ID right so like that same things we will to use like over here like DB context and set and find by the ID what whatever ID I have to pass I will get it and return back and same things for that add add one so here again simple implementation for that add one so using that here and as sync and using blog DB Contex set and then add a sync whatever entities we have to pass we have to add it over here then finally we have to change that uh save changes and then return back to entity whatever newly entity has been created right and then same things for that update go to that update one so again uh we have to implement that update so it is again uh using that blog DB context and here let me add you know a sync and then just we have to make sure okay if any changes over there it is modified right State the changes so whatever entities we have to changes they will modify and update it right so like that and also one last thing actually we have to do that delete one so let me complete the delete also so same things we have to do delete so whatever DB context set right and let me add this guy whatever DB context we have to set that we have to just you know pass it over here and then finally save changes and we have to remove from here first and sa changes so this is a concrete implementation of uh no generic repository like so this is done so once it's done right so what I can do uh I have to require actually some seeding data so that once our application is run so uh some data should be automatically I know migrate and uh created our database and insert it over here right so let me create uh one folder over here let me create that guy and make it a seeding data seed data right and in this SE data I have to just create a one static class and right click on that using a class use that name initializing Anon and here what I will do static make it a static class and make it that method over here as a static like that right so see I just created one method static method which will accept you know our DV context and here I have to check first if it is any blocks over there like in the block tabl say contain any blocks right so if it is blocks content then simply return either what I can do uh if it is contain then it is returning if it is not then I was just adding some blogs uh as a data right and then let me create some data over here see this is the data I just created a new blogs and we have just added specify you know some blogs and then finally here what I will will do I just add our data to our database right so let me add it over here like that actually right so like this way actually you can do that and other things also we can do that using if it is uh any if it is any right so let me add this guy for example use this guy if condition inside this if condition we have to add like that so this is another way because we have to trying to use two entities right so that's why I using but if you using only one entity that is fine perfectly fine so this is done right and then what I am trying to do over here so if it is any uh if it is not any right if it is not any then if it is false then you have to trying to add right so that is one and then another thing seat data we required that is author right so let me quickly create that one also like after that I'll just create this guy and also we have to do same things from here uh not equal to right and if it is not equal to true then what I can do I just create you know some seeding data of that author as well so now I just creating some author data fake data and here what I'm trying to do uh inside this I just need to add and save changes our entities like that right so like that actually we have to uh seeding data but yeah there's a many way which we can use but yeah this is a simple way I have to use over here and then seting data also completed right so now uh everything almost completed and now one more thing actually I'll show you over here um which is actually record in this structure so let me add another folder let is call services right so services so whatever your service is right so see this is the implementation of your repository so whatever repository you want to implement you can Implement inside this repository but yeah additionally suppose you want to use some Services right so which is not interact any database and all right so it is a directly as a service so that service you can just create it over here so as of now I'll show you as a sample service for example will uh for example Azor service service bus services right service so if you if do you have any services in your applications right so that you can keep it in this Services folder you can Implement over here but yeah in the application layer you can just create your your contact over here inside the interface and Implement in this services so that you can you know separation uh separation is a important right so they you can just clean you can just use it as a clean approach right so that why you can just separate your services so now almost all the structure has been done except one things right so that is a extension so also see whatever dependencies over here right so that also we have to resolve that dependency for example whatever concrete class like suppose we have to using this repository uh concretions right which will inject in our somewhere and also Services we have so everything we have to resolve our dependencies in this in this layer as well and also we have a Blog DB context right so that also we have to record the dependencies in this case what I can do again simply I have to just create another extension method for this particular infrastructure that is called extensions right in this extensions method I have to just create uh one extension method for that here so whatever extension method you have to create you can just create it over here so my first extension method would be the infrastructure dependency resolve registrations so here I just create a public right and then make it to static and similar way what we have done in our previously right for that application layer same thing we have to do that public right static and then I have to call that I service I service collection which is coming from here right and here see uh I am using extension dependency injection right so that's why I'm using I service collection and then I have to use whatever our you know method name so my method name would be this guy and then use this things and additionally what I have to do I have to just pass our you know uh something you know I configurations interface right let me bring back that I configuration interface because we require some uh configuration from that our application layer uh our you know uh presentation layer right so because we using that whatever configuration we have like whatever app settings we have right so if you require something so that's why we have to add this guy and we can use it in our requirement perspective like that we can just create it now simply return your services over here and then here I just just resolve all the dependencies so as of now we have a three depend two dependencies over here right so first dependency is our you know that uh Guy where is that no block T context right so that we have to resolve first so how we can resolve let me Services dot add DB context right and this add DB context use that whatever your D context name my DV context name does this and use that Lambda functions over here and in this this Lambda functions what I can do I can use that that bring back over here use that options dot options dot use your uh SQL Server right so use SQL Server where because as of now we are using SQL server and here I have to get that connection string name we have to pass actually connection string name over here so we I can get we can get from this configuration right so let me config dot get connection string and here you can pass your key name right so whatever key name suppose for example it is a clean this is the name clean architecture skeleton DB and then finally we have to do some additionally over here uh for example there is a one more mechanism over here in EF core provider that is called uh retry mechanism if it is fail so it they will try to retry don't worry about that if you new for this concept so go to my channel and definitely I just I I just created actually one session for enable retry on failure so the separate session I have just created for this concept so you can just check it and now see our one res uh dependency resolve has been done which is a Blog DB context right and they required something else right right so yeah now see this is done and then what others we have in this infrastructure now we have a repository right which is a generic repository so that also we have to resolve using that Services dot add scope right and inside what I can do I can use a type of uh add scope using that different bracket type of and in this type of what I can do I have to pass my I repository right and that's it and then whatever implementation concrete class right so that also we have to use that type of and then that's it right so this is the way uh we can resolve our generic repository uh repository implementation right and then if you record further uh your dependency so as of now we we have only this way so we have to do like this right also um this two things but yeah in up in up in in later actually we have to do many things so that um many things so that also we will do Implement right so let me save it right so now we have to go to create the folder structure right so this is the way we can create our folder structure and uh project structure of the clean architecture right so this is done now we have to H start to implementation our feature right so let me go back to again that application layer right in this application layer okay before that let me just build this solution so that we can make sure whatever we have done that is perfectly fine or not right so now see it's perfectly fine right so build is succeed now uh let me start to implementation of features right because everything we have to covered now we have to start our features so first I will just start a feature first uh uh using the blog features we will using that you know queries one so let me uh create a new folder over here inside this query that is called let me call that get blogs right because this picture and uh in this feature like you know query we have to return all that get blocks right so that's why I just create a get blogs and inside that what I'm trying to do let me create a one query right so my first query class would be uh here get blocks blocks queries and let me create that to get blocks query and here make it a public and here I just we have to require actually one response so what would be the response of that get blocks right so let me quickly create again another class uh that is a response so quickly I just create that response let me create a response here so this is my response make it again public right and this public let me call that actually inherit That Base response which we have to create it right so base response which we have in this you know application layer here that response right so we have to bring that response so that whatever that common response we have to return back like that and if you want some additional responses response in to user so you can add it over so what is my additional response would be so my additional response would be I'm just returning any list of the blogs right so let me create that list of blog dto in this here so if it is common things right suppose something is common in your application layer so you can just keep it over here like you know in this features for example this is a features right in this features uh if you if you think something is common which will use all the features so I can create the common things over here inside that so what I will do I just created in know one blog dets for here in this inside that feature folder and let me add and here make it to public and in this public what I can do I have to just you know uh have to add this property over here whatever requir we have this property so we have to require you know name and description but ID also required but that ID also is a common property right so that why what I can do over here I can just create you know another uh you know Common property uh common folder uh common common file uh which is a base a base dto right so let me create a base dto base dto over here and in this base dto what I can do simply I can just create you know one ID parameter so that it is a common for that all entity right so that's why I just create a base D so that I don't repeat id id property for the all the entities right so let me copy this guy go back to your you know blog dtos and just inherit so now our requirement has been completed right so this property we required name and all and whatever ID we required we can just inherit and we can just complete it our dto part over here so this dto we have to just return back our response so go to blog section here had our response folder right here I just have to create uh property which will return uh that the I will just simply return list of that blog d right and then make it it that name is a blocks so this will be written as a blocks right so like that see this is simply I just create a response which will return all the blocks right along with that base response whatever the default response right so like that now go back to your query here I have to use that I request uh which will use that mediator all right so this is a responsibility of that mediator are which will be have required That Base response so what is my response my response name is get uh get blocks response right so this is query we have to just create a query things right and if you if you want to some additional parameter passing to that get blogs right get blogs query so you can just add it over here your uh additional additional queries parameter which will be accept uh from that uh user right so that is done right so now uh that query and response has been created now we have to we have to require you know one uh Handler right so let me create a Handler as well let me create a new class and here I have to create you know query blogs Handler so get blogs query Handler addit and in this just make it to public and just inherit over here I request Handler this is is part of that mediator right and here they accept two things right what is the your you know request you know request query and what is the response right so they expect this see T request and T response so what is my response my response again uh like that get uh get blocks response and it will be Implement one method which is overload method uh let me Implement that see now we have a handle method which will actually whatever you know this whenever you call this you know query block so they will call this Handler and the Handler call with this method and whatever implementation we have to do over here right so now we are good to start our implementation over here so first what I can do just let me create a Constructor over here and then here I need to inject our generic repository see there is a we just created uh our repository right uh which we have a interface right so this repository this is our contract contract contract right and this contract we can use this here and we can use all that we can pass that generic uh know entities and we can use that all the methods so now first I will show you using that genic uh things and then we will use that extendable repository as well right so let me use that first no I repository so let me pass this guy I repository and then whatever entity you want just pass it so I will use blog because I require blog so once we add the blog entity so see there's some error right so actually we required some uh name space but yeah we have already added the name space but this name space is not sometime is working so what I can do directly I can specify over here right so like this way you can use it but yeah another way you can use like like use that you know something uh uh just store something like okay domain entity right domain entity and using this guy and then you can use in a short way also like for example like that right so this also it's working fine but yeah that is perfectly not a good way but yeah it should be bring but yeah some sometimes actually it is the treated okay it is a duplicate our application so that way actually it is not bring back but yeah that is fine up to you so let me add this guy and then what I can do let me create a repository uh variable so now U we are good to go right so now what additionally things we have to do over here we have to require some mapper right because we have to require the conversion so let me add that mapper as well so let me add that mapper and then use that mapper and then one last thing we have to use that I logger right because we have to trying to log something so we can use that logger so what is my logger class will be Implement over here this is that logger and let me bring back so let me bring back over here right and then store a variable and then let me injected everything like for example first I just to create a uh assign and field and assign the repository right and then second one is a this guy and then third one is that logger one so let me add this logger as well and then we can just remove these things we don't require actually specify over here as well now see now we have to injected our Constructor right and now we are good to go to use this repository now let me start over here so first let me create a variable over here uh for example I will just return for the response of that right and then uh what I need to do as of now actually see uh there's some validation part also there right so let me quickly create a validations for example uh see be using that fluent API validations right see F validations so what I am trying to do so whatever actually uh validation suppose something is happening uh which is not uh meet our business rules right so we we can try to get a validations and we can return back to user so for that validations we have to create you know another class which will you taken care of our validations so like we we can use validations over here like that see I just created this guy and make it that validation for example Flint uh sorry abstraction abstraction validations and here you can just pass whatever your query so my query name is get Block query right and inside that we create a Constructor and inside this Constructor whatever your rules right so that you can just edit your rules over here but yeah as of now see we are not passing any parameter in this in this uh query right so that's why we don't require anything but yeah I just show you for that you know standard Pro prospective because every every you know Handler actually required that same process like okay first we check that validations and then proceed if it is Success right so that's why actually I just created over here so once I created that validation part as of now nothing but yeah uh we can use an uh later part for example like that see I just use that whatever validation if required I can use it like that and we can add it but don't worry about that we can cover this validation in our get by blogs ID because as of now we don't reord validation for this features but yeah in uh later one we require that so this is done once it's done again here I can just create a variables for that right for validation variables and here what I can do simply first just try using a create a trius block in the strike as block actually we have to create everything from this here so that our exception also we can handle over here right so what I can do first I have to just whatever you know that validator right so that validator I have to just uh know bring back that things like that so here I just create a validation result using that await validator whatever validator and using that validat sing but here uh we using a so definitely we have to require that syn synchronize method and then we have to store that validation result so whatever validation result suppose if it is fail something we can just returning back to our this validation result right this is a simple things and then in here we have to just check know one condition if it is if it is validations result count is there if it is created then then first I have to just set is Success whatever you know by default as the response if you see see if you go to response see whatever property we have we have blocks success and all right because we have inherit this response uh base response right so that's why we have blogs as well as success and others validations part right so first I have to do just set is is a false because if it is validation fail so our response would be as a false so that's why we have to set as a false and then make it a empty string uh of that result right whatever validations we have just make it to empty because first we have to just initialize right the empty and then we have to iterate through uh Le for each Loop whatever validations we have to get suppose we have to get something then we have to iterate for each Loop for example for each right in this 4 each what I will trying to do I just name change it to name for example error and then validator right so whatever that validations not a validator right what we have that information over here right so using that validators and then result and Dot errors right so whatever errors we will get using that errors method and then here what I will try to do we will try to select and in this select uh which one we have to tr to select we have to select something for example x dot using the Lambda expression and you can get that all the property we will require that error message so whatever error message we requir we have to re we have to just Fetch and store this errors and then we have to add one by one inside this validator error message right so like that we can just add whatever message in this get response using add this message and then finally we can add some logging over here for example let me add something okay validation failed due to this error right so like that actually we can cover our validations right so in this way you can handle the validations once is done Suppose there is a no error in this validations right so then then I have to check okay if it is if it is Els if it is Success then we have to try to another blog here and this in this blog what I'm trying to do whatever our repository right so see it is my this is my repository right so here let me store as a variable result let me create a result and using a wait and use that reposit dot see we got all that and of that method right so update delete everything right so in this case what we required we require Reed get alls right so this is the method we required and here they expect nothing right because we don't have passing anything so now once you call this repository do this guy you will get that Reno result and in this result what I'm trying to do see this result return this result return that entities right but we have to return see our response if you see that response for example this is uh this is important actually see once I try to this guy see this is return dto so here we actually come in the picture the conversion like whatever entity we have received we have to just convert to our dto so what I can try to do that's why actually I just injecting this guy like mapper right so I have to use that mapper over here first what I can try to do let me uh directly over here like imapper imapper do map and here I just pass to list and whatever list we have trying to get over here so we have to conver whatever type of list so I will to convert to blog D so this is blog D I want to convert and which is our source where is actually Source our source is this which will return return our entity right all the list entity we have return over here that we have to pass to to source and they will map to over here so like this way actually we can clean approach we can just conversion our dto right so like that we can do that and that's it so once it's done now the last thing actually we have to just if something is happening and know while processing something and happening in error and all so we can keep it over here as error so first we can just log it over here so let me log it right and then once you log it so also we can just add uh our response for example success whatever B by default is true so that I said is a false and whatever message so as of now I just pass it directly whatever exception message over here but that is the good idea so whatever your message you can just manipulate and you can add it so that user can see uh that whatever message you want right so this is actually idea let me add something uh like conver to your own message to show user right that you can just add it additionally add it over here so that is fine right so this is looks good now finally we have to return so what is my return type my return type would be about this guy right so once I done now see our implementation has been completed right but here see there's a one error issue actually so once I conversion over here see I just specifi tell okay I want to conver was imapper imapper just convert this dto to no this source to this dto right so I'm just telling but where we have to specify this these things actually we have to specify something which I already created in this application layer right that is called this profile so now it comes comes in the pictures maing profile so here what I am trying to do I have to just simply map over here for example create map and here whatever know domain entity right so you can just specify so my domain entity would be like that blog and then what is our Dio so that you can just specify blog Dio right and here you can just Brack it over here and then in here actually you can just specify if it is both are common there's no issue suppose it is common for name and also if you go back here so this is also common right so there's nothing we have to handle but yeah additionally if you if we have you know something for example uh that is not common right so then what I can trying to do simply uh like that for member and whatever your destination and whatever your in know Source if you something for example it is not like that suppose we have destination name one right or or just you can say it is a title right so we have a title and then we have to map to name right so then we have to forcefully tells like that but yeah as of now we have a common name so we don't require that and then finally we have to use that reverse function map right so that it will actually handle like both ways like if you want to uh no if you want to convert block to you know entity to dto that is fine but if you want to D to entity also that use this guy so you don't don't record again to specify that things right so it will manage actually both way so like that actually you can just mapping over here so once you map so now we are good to go to our implementation of that right so now I think everything is looks good right for the first implementation of that first feature so once you complete the first feature what I'm trying to do I will just try to implement our UI like which is the presentation layer and then see okay uh this it is working fine or not so once you uh once you working fine then we have to implement that uh next feature right so let me create over here let me go to here let me remove this guy the what is the default controller so let me add a new controller over here so what is my new controller name would be my new controller name would be as a empty controller and then make it that name is a uh blog right so let me create a blog and here actually one common feature actually we required that mapper uh yeah that mediator R right so that mediator are be required that all that controller right so that's why the good practice over here we have to create you know that uh that a separate uh controller which is a base controller which we can use that guys so let me create a controller use that base controller over over here again right and that make it that name API let me create that one and then once you create this guy right we have to decorate something over here so here uh I just created That Base controller and here what I can do let me add uh let me add another one property for example like that right like I sender but here see this I sender is not present over here why because we required some mediator r package and all so what I can do Simply Now now I have to you know add some reference like whatever the reference so this our presentation layer actually uh not directly reference but indirectly indirectly reference would be of our application layer and our infrastructure layer right so those two reference actually required in this year so let me add that reference for example add reference over here of application layer and infrastructure layer let me add this two reference and add it over here so once you add now we are good to go to that because we have already you know that things for example see because we have already those packages on that uh that uh layer right so that's why we are bring back that name space and we are good to go right now we are good now finally what I trying to do I just create you know another uh another uh another method uh let me call is that the mediator R right so that mediator R just initialize whatever property we have to set right and then specify okay if it is not it is empty and all right it is a null then bring back from here the I sender right so like that we have to set our base controller over here and then we have to to go to use this guy to all our the place right all over the application so go to that your block controller here let me simply add this guy API based controller and then we have to uh we have to use this guy over here so first let me create a one endpoint so my endpoint would be over here that HTTP get endpoint and then I have to just create you know one method over here that is called you know public aing task action result and this would be a response timee what is my response type which we already created right so if you go back to here see this is my response type which will return return blogs entity and along with this base response right so that I just created and then here simply it's a clean approach actually here we are to use like where response and here using that await and then use that mediator R so where is our mediator R mediator R is is using inside this application controller base so that is coming from here and then using that send method and in this send method use that whatever your query so my query would be get blogs query right and this is your query and Simple and Clean approach now see it is not directly uh dependent that application layer right because this application layer has that contracted right that query and all but that is we are not directly using but yeah indirectly we are trying to use that mediator R and calling that application layer and that application layer actually uh do process further and then return back to your response and then whatever response you're trying to get over here simply you can just return over here right so like that you can simply just return back to here right so this is actually way uh the flow actually working like using that medat ER calling that blog query no no query class for your application layer and then application layer actually call you know talk with your Handler and this Handler again it will talk for the first you it will check you know your validation part if it is clean then it will call your you know get all application method which is actually Implement in our you know infrastructure layer if it is here infrastructure layer and then infrastructure layer talk with the database and database will be return back to data and data over comes over here and then finally we have to map and then return back to our controller here and then UI right so this is actually complete flow of that clean architecture right and that is done now what I'm trying to do actually one thing actually uh we have to do over here uh that is called something some additionally package actually also be record in here you know and this our presentation uh e layer right so here what are the package actually required so it is required because you know uh some migration be required of EF core right so that's why this two package actually required so first package is be let me add that package add reference or not like that let me new get package right go to that new get package here first package actually we required a design design package right so let me add one design package so this guy let me add this guy and then another one is a tools dative framework tools one so let me add this guy so this two package actually required for that migration you know that EF core migration so that's why we have to add this two package right so let me add quickly so once it's done now we are good to go now we have to add you know whatever defund is actually extension method we have to create that particular application layer right suppose application layer we have that uh this extension method right application di registration and also infrastructure have that uh this guy right so those things we have to uh resolve actually we have to call in our here go to that API layer means no presentation API project and go to that program CS file and in this program. CS file you have to call those uh registration right so before that you know before app builder what I am trying to do here let that Builder dot Services Dot and that dot uh whatever my method name My Method name would be uh add application uh let me call that name actually I don't remember remember that name yeah that's why I go to back here uh copy this name go back to here and then call that method and then simply so call that I know add application service method if is still there so what I can do simply just space and just bring back and it is just using your you know uh name space so once you get that name space if it is not there if it is not coming automatically so just you can just forcefully add you know using and whatever your name space right so you can just add you will get that things right so like that you can add it and now second one uh this is our application layer right so application layer and then second one would be your uh infra layer so let me quickly add that guy also Builder do Services dot uh what is the name of that guy let me quickly go back to here that name of that guy is ADD infra so go back to here call it to that guy and then just bring that and that's it yeah now it's also coming but yeah see it is expecting actually uh the parameter right so that we have to uh passing that IE configuration so where I can get I can get from that Builder so let me call that Builder dot configurations right so that's it right so now see these two uh dependencies right this two extension method we have to uh register over here like this way and this is done now one more thing actually I miss that in the infrastructure layer that is the startup things okay so now go back to go back to infrastructure layer now see I just creating a seed data but see I have never used now in our somewhere to that see data so how they will generate and create that data and all right so that part is missing so what I can do let me create another extension method quickly so that part is missing right so let me quickly create that method name would be now startup DV extension right so let me call this guy startup DV extension and here what I'm trying to do make it public right and this make it public and static and here I have to just create know one method uh which will just check if it is Data if it is DB exist or not if it is not exist so it will create for me and also I will use that you know this extension method of host ihost know web Builder so which is coming from that extension hosting but uh Microsoft extension hosting so that's why actually I have add this package right so this package actually I have just add it for that so like that so now I'm good to go now what I am trying to do I have to just create a scope right so using that host I just create a scope and then I have to just create that service over here and then we are good we are creating a service as well from that know scope and it is returning that I service provider and then what I'm trying to do simply whatever our context right that context uh we can get it from here like that uh whatever our context we have to just store for example this guy service. getet request and whatever our blog context store that you know blog context and this block context I I have to just you know make sure like okay whatever the block context it is properly created or not if it is not created then let me create for me right so like that actually what I am trying to do over here let me create a TR cat so that if any exception so let me make it that and then inside that what I'm trying to do one relations Creator uh variable we have to just create it for like that right so let me change it to that right okay so now DV context data get the service I data base creation service which is coming from C we have core for storage like I data service created and then we have to create another data created but yeah if it is not it is new for you but yeah this is fine because see I just many many Place actually I do these things and separate things so that's why I'm not going to details of that but yeah this is the way actually if you want to Auto auto migrations if you want to create a auto migration in a application so you can do that but it is a simplest way uh which is a best way actually so that's why I just creating this guy and then finally what I'm trying to do I just have to create you know the D creation all so let me create that all so that I'm not writing again cuz this is many many Place actually I have to do that okay so now see I just store as a DB created right DB DB database Creator and if it is not n then I'm telling okay database it is connected if it is not connected then just create it for me and also whatever tables we have if it is not created so let me create for me like that actually we have we can just Implement and this logger part also it's missing right so let me create quickly as a logger uh over here let me add this logger so quickly let me add that service of that loggers right and then we are missing something over there okay so see the try cach we have missing something let me add complete that so once is done now see now your DB set has been created right but but still we have not uh now telling okay whatever your seat data which we have to try to create right so your table has been created and DB also created but where is the data which we are to trying to seeding so that we have to call about that uh static method right that is called you know data set uh not outside actually you have to just bring back to inside that data set initialize whatever your DB context so my DB cont text would be this guy so let me call this guy this is my DB set and here just pass or just create and that that is done now again missing something over here so what is the missing okay there's extra extra here right so yeah like that see this is complete flow right of that creation on migration of DB automatically so this is the way and then um in this last actually just simply we can add a logs over here so if it is fails so something we have to tr to log so like that see this is the extension method we have to create it and this method we have to call in our startup do file right so if you go to that your application web application folder uh layer and go to that program. CS file here before Here app do using that create if not exist right so see this is that method and you can simply use this method so that once your application will run so that migration you know this extension will be called and whatever migration we have to tell they will migrate right this is the one way but yeah this is the auto way right so if you don't want to use so forcefully you have to just try to migrate uh yourself like using that no command add migration and update migration right so both way I'll show you both way don't worry about that so that is done so once you save now I have to add you know one con connection string like so go to that you know application do setting file so let me add my connection sting now see I just using this connection string but yeah we have to change my name right on connection string is very simple right whatever your SQL connection string you can just keep it and here I will change the DB name as well like for example will clean architecture DV right and then also the name whatever I just set it in our program do in our insection layer uh in our here see this is my name so whatever name I can just keep it over here same name I just have to keep it over here because I will get that name same right so I just keep it this guy so now we are good to go to run our application let me uh build and see the actions what happened right now see build is succeed now just try to run and just before run what you trying to do see is this is just select a domain project right so what you can do you can just set your startup project of this web application or yeah this guy like set as a startup project like this way and then just start now see we are getting one error right so it is just asking cannot initiate the implementation type of that ID pository right so something actually we have missed to you know resolve the dependency of ID depository right so we are actually we have that resolve that our dependency so in this our extension method in the infrastructure layer so go to that infrastructure layer in here if you go to that extension method and go to the infrastructure layer dependencies on here let me check what we have actually missed that now see the problem so problem is here I just see this is our contract and this is our implementation but I just missed to implementation class to specify over here which is just simply repository right so what I can do simply just remove that guy right and then bring back that uh name space name space right repository and once you get now save and just stop that and run it again now see this time is running perfectly and if I see uh that see our DB also has been created right in this console if you see that logs actually happen it's just creating your author creating the blogs and just inserting whatever the seat data they also just adding on your seat data right so everything is good and let me check over here okay by default I just closing okay don't worry let me run one more time now it's running and let me check it's uh data is retrieving or not right so see our data also is retrieving perfectly right so I'll show you the flow actually how we can get this you know things uh and get back to over here right so let me uh put the debugger point from the controller for first go to your controller uh here right so not here go to that here bring uh no put that controller over here and also this here and go to that application layer go to feature application query and if you here I don't think we can keep it any here but yeah uh we can use the here Handler right once you Handler and also I can put the debugger point in infrastructure layer as well go to that implementation of the repository and that get all method right so here so now I'll show you the flow actually where actually they retrieving the data so execute once you execute see first it is going to our controller right and controller will send this query so let me go to F10 once we have 10 now see it is going to our query Handler right and in this Handler they will call and set initialize everything and they will validate right so as of now see there's a no validation set and all right and then it will go to that success one and if you go to that success one and it's also calling that repository infrastructure layer repository and here they will call connect with the database and they will return back and you will get that all that entities over here right and then after that that mapping will be just mapped to our this entity uh this dto and come back to your here go back to your controller back to your response and that response will be shown to the UI so this is actually complete flow so that is fine and that is uh good to learn over here and then now the next step would be now we will Implement all other features for example get by ID and insert up the delete command and then also so we will Implement in this session like you know now as of now see if you go to that Handler I'm using that you know generic repository right so how we can use that you know extendable repository as well instead of that generic repository right which will only provide you know about that common functionality but if you require something we have additionally we have to do that right in our repository level suppose I want to get the N uh get the blogs by the name right so that we have not used using we can't provide this you know generic repository that we have to require that extendable repository we have to create it so how we can create it how we can use it that also we can we will cover in this session right so don't worry about that keep it and continue to learning and now now let me move it to the next right so which is actually a get by ID so inside this query what I will do I'll just create another feature that is called gety ID and now I'm not going to writing any code because everything I just explained right so now I just Implement you know just copy paste things because it will just taking time right it will al already take a long time so what I will do simply just create a query class over here go to here go to class using that query class and inside this query class just you know I just use change it over here like that okay I will just use this guy uh and and just actually one one more thing actually we required uh here the base command query because see uh if we required you know some additional parameter which is common for this all the application feature so that I can just use it at a common uh common things right so that is a called a base command here so let me copy this guy inside this features so create that create a class use this guy and in this here what I will do make it public and create property and I will use that ID and okay let me use that integer or whatever things you want you just use it and here you can just create you know you know suppose for example block ID block ID we require you know many many features right suppose if I try to update and delete we require that block ID and also so we requir the get by ID so also we requir that block ID so this is a common things right so instead of create again uh same property for the all the request we can create you know Common uh query or command class no Base Class which we can inherit and we can use it so it is a reusable things right so that's why we can use it so what I can do instead of block ID I will use that ID so that all kind of ID like suppose our blog ID or or you know author ID or any ID actually we can use it so let me copy this guy go back to here now see this is done and then also we have to create this you know response as well whatever response type for this you know get by ID so let me create that get by ID response as well and here uh it should be a simple response of as like we have done right so let me create that response and this response would be our blog entity that's it it's simple blog entity and we have to bring back to base base response that's it so now work qu uh implementation done now moving back to our you know Handler now create a new Handler right click on that go to here class now copy to that Handler create the Handler and here let me change it to public and just now uh inherit that inherit that you know I request Handler which is actually um query and response and then bring back to that implementation and here what I can do simply I just you know injected to our Constructor create a Constructor injected and then we have to just bring back to that name space blog but blog is not there so what I can do simply what we have done previously same thing we have to do that here the domain entity domain do entity do block we can use that and then once it's done let me inject it to over here and also mapper let me inject it to mapper and also logger let me inject to logger as well I remove this which we have done already so that is done now injected is ready now we can start our implementation so again just create all these things like first just create a blog response and then again we have to just create uh validator now see here we requ some validator right because whatever ID we are passing that ID can can be used or cannot be used right so it is exist or not or this is a proper IDE or not that we have to check in this validator so let me quickly just create a validator class as well inside this here let me create that guy and this is the validator and in this validator what I'm trying to do simply inherit this guy right which is a query and then in in using that fluent eii and make it public and create a Constructor over here create a Constructor and just edit our validation so now see this is the way actually we can using the validation and here if you see in this whatever you know in this command you know query blog by ID query whatever property you have it be available over here so now it available ID right so we can use that ID and that's it and then I just set it okay if it is greater than zero right so then what I'm trying to do okay greater than greater than zero right so this is just checking a rules and based on the rules they will returning back to over here so like that okay so now we have to do same things for that what we have done right so let me add this over here like validations and all same things what we have done in previously so using the try and just using for here s sync method now see I just store again that validation result whatever validation result we have just capturing over here once is not validation result over here here so what we'll do just success one we have to call that you know get by ID method and pass it to or whatever ID and this will go to the infrastructure layer and get back to the result and result just simply you know uh convert it to over here and return back to here now see this is the easy easiest actually easiest way we can Implement so now get by ID also Implement now let me run it and check it it is working fine or not okay so that feature has been implement but I have not Implement that a controller level right UI level so what I can do simply close that go to that UI go to that user interface presentation layer go to that blog and here I have to just simply add that another endpoint that is call HTTP get and call the parameter one right so now see uh I just using the get get ID passing the ID as a route parameter and here I just pass the ID and this ID see this is a parameterless query but this is a parameter right so I just pass the whatever parameter so this is ID and whatever ID you are getting just assigned to that ID in this query let's see in this query we have that base query right the base query accept that ID these ID we have over here and then we assign this ID and pass it to that it will just pass it then it will go to our Handler Handler go to the repository and all other feature whatever feature we just Implement right that will call and get back to over here let me run now see our blog by ID so whatever we have ID so let me check first so it is uh debugging mode so let me continue quickly once you continue now see we have the data like let me I want to data of three so let me add this three execute now I'm getting the data right so expected result and if I just pass to zero right once we execute now see I'm getting that validations because zero is not expected right and also if it not exist something so it will just getting and but it is returning null right because the data is not exist right that also we can just using the validation okay if data exist not exist so also we have to show or not like okay it is some validation error and all but it's not actually s business rules right so that's why actually I'm not edit but yeah that is fine now uh this is also done now we have to move to next one next feature which is a uh insert the blogs so go to that create that quickly go to again and here I will just create another feature which is uh Command right so let me create that command so create block so let me create that uh folder feature folder it is a create blog and in here I just to create a command so this is a command implementation so is it should be a slightly different but yeah almost use the common uh up approach right so first I just as like we have to create a query so same things we have to create a command and again we have to just in inherit that I request to whatever response so let me quickly create a response whatever that create uh blog should be a response so let me create a response create blog response and inside again same things we have to do let me add that base response and this base response respon uh this is a base response but yeah uh we have to return something right so we have to return over here as a Blog ID right so let me add as a Blog ID additionally parameter as a responses because we have to return response so now our response got ready uh here and let me uh let me quickly add that response I request response over here right now our Command has been created now go to here now we have to create a Handler so create a new Handler for example blog create blog Handler so this is my Handler create blog Handler make it to public same approach we have to do that again inherit that you know that uh I request command and response right same thing just inherit that I request command and Handler and just bring back that interface here and also it's done now same things we have to do that right we have to just now create a Constructor and initialize that value all that things right which we have to done already now see same things we have to just done so I just inject that ID depository and mapper and then logger and just be up to that bring back that guy domain do entity do this right same things we have to just do over here right and that's it right so this is done now injected all the things now we have to go to go to use over here again we have to just simply we have to just create a response right create a response object and then we have to just require that validation now here again we have to record some validation right so let me create a validation class as well uh go to here here create a create blog validations and just inherit that guy of that abstract uh validations right so let me bring back and just use that abstract validation for the create message and here I will just create a few validations inside that create a Constructor and just use that whatever uh uh whatever things actually now see the create command then create command actually I missed something right so see in this create command we actually required whatever you know that uh whatever that entity right suppose description name and ID right ID is not required but yeah name and description is required so that actually I missed that that also we have to record using that you know create command so what I can do I just simply use that know as a property like blog entity see this blog entity we have the name and description so just simply we have to just create it right and go back to your here and just return here now see now we are good to go to see we have to set the rules of that you know this name property and then description property if it is null or empty so it will return back okay it should not be null and should not be empty right so like that we just set as a validator and go go back to here Handler and just simply uh we can just create a validator like that right and then we have to again just using a TR cat block over here like that see I just using Tri block and just make it to a sync and here simply again the same thing common things like we have to just trying to validate if it is validate or not if it is not validate so we return back over here it is validate so then there's a it is some issue so what I'm trying to do if it is Success the validation is Success so what I'm trying to do I just you know know just you know whatever you know request we have received right so see this is a something uh different whatever response we have to get we just trying to again convert to our entity like see this is our entity so let me bring back domain domain do entity and blog right so this is just conversion again so whatever uh conversion I want to convert to dto to entity this time and then once I get the D to entity I just use that add sync method which is coming from a repository and then pass it to here and get the result and whatever result we are getting that assigned over here that's it right so this is common this is a common way actually same things we have get by ID on get all method so same approach we have to use uh for that create as well but it's something different for the command and right so this is done now feature has been done now uh let me Implement in our here uh for the block controller for the UI and it should be simple again we have to create a post method for that go to down here let me create a post method and just using that know blog dto right which is just expect whatever entities of that blog dto and just using that create command and pass it to your command and that's it right using that mediator R which is coming from that here already I just explained and let me run it and see in actions now see uh our post and point also exposed now I just trying to add something so before add I just see I just remove that guy just remove that guy if you trying to execute I will just get those validation because I said this validation right if it is not should not be empty so what I'm trying to do simply I just pass something for example there is a clean architecture scalon right and then simply architecture skeleton I just pass it over here and then execute once you execute uh it is saying something some issue right the command field is required okay now see um that is correct actually I miss uh over here I just pass it to this see this is the problem I just wrongly actually I added uh some additionally double code so that's why once I execute now see I'm just getting ID number four which is I can check over here get y ID uh get all okay again it's a debugger mode so let me quickly continue so now this is newly Blog has been created with this feature right so this is easy uh way to create it right so let me close that now move it to next one which is should be update one right so see we have complete three one now update and delete is pending now go back to update one so now go to Features right so here like create has been done now we have to create that one update one so let me create another features over here inside this command let me add that name so blogs right update blogs and inside this update blocks I will just create a command that is called Command right so update command create that command update block command make it public and also so we have to use that ID because in this in this uh you know update we have to require ID right so I will use that base command which is returning ID and also we have to record response so let me create that response as well we don't have a response in this feature so let me create so let me create that update blog response and in this update block response I have to just create uh I I just inherit simply that uh base response nothing I have to do over here and only just make it to public and go back to here and let me bring back to that uh name space and save it go back to here and now uh our Command has been created right so what I am to do actually in this command we require two things right ID uh what which ID actually we trying to update and what whatever that properties right so I just required some data which which actually we trying to update so I just want to update you know some few properties right so for example name and description and all right so that we have to just pass it as a command right so that's that is command actually created now we have to create that Handler go to that Handler uh create that Handler actually so go to that here and create that Handler class let me create quickly over here and make it to public and in this Handler again we just inherit you know that I request Handler over here and which is this expected over here request and response Implement that and then again same things we have to do that what we have done last time so let me just create a Constructor or inject that know blog repository mapper and logger this is a common things we reord for everywhere and then and just domain. entity do that guy and this is actually creating problem so yeah so let me add this guy and that's it so once you add so now we are good to go to implementation and before implementation again we have to require you know some validation uh validations class right so let me create also validations let me create a validations make it public and in this validations we have to do something additionally over here right so first let me whatever trying to do uh let me create a Constructor and create two uh validations and before validation start we have to just inherit you know that abstract uh Command right let me inherit that so once you inherit now see our two validations over there right one is the name and property that should be not null right so that is fine now one additionally whatever ID actually see this in this command we are passing uh some ID right based on this ID we are trying to update so in this update suppose this ID is not exist so there's no Mak sense to update that thing so that validation also we have to taken care right so go back to go back to here uh go back to your you know uh here here what I can do I have to just create one more method right uh that will actually just maintain okay it is exist or not so how we can do that so let me create quickly one method uh for example after this let me create a one private method and here we have to just pass you know one blog ID and then pass it to cancellation token and just check if is is exist blog or not right for that is exist log actually we required you know that repository right because where I can get I can find that okay data so what I can do in this Constructor label I can just inject our repository you know generic repository to get that information so simply again domain do entity and do blog right and just create a depository and inject it over here so injected that once you inject now see I can get I can use this repository and this in this repository I can find okay it is exist or not right so let me quickly using the weit repository dot get y ID and this in this ID what I'm trying to do I just adding this passing this ID and just we can get it over here it is finder not so let me store as a Blog right blog I just getting the blogs BAS on this ID and then here simply what I can do trying to check first okay the blogs right if it is block should not be notable and then his ID it is greater than greater than zero that means ID is exist if it is not that means ID is not exist right so that make me actually true or false returning and this true false actually we have to compare in our rules which is supported over here right so what you can do simply you can just keep it on the top this guy and here we have to do some additionally uh additionally uh rules like for example rules rule for okay actually I just close it that guy that why it is not available so what I can do rules rule four right and this rules four let me check which one I'm trying to do I'm just trying to do block ID right or just ID right it's just ID and this ID uh using that method must as sync like there are two method so it is must as sync you can just pass whatever your method name right so which we have just created over here just edit this guy and then it will just check it okay it is true or false based on this we can just set it our message okay uh like like okay uh this message means it should be uh does not exist or not right so let me do like that way right is simply whatever you just creating a method as a Boolean method you can just pass it it will handle and they will return back to response right so like that our you know validation class also handled now go back to that Handler and here I just use that Handler method uh over here but yeah here additionally we to do that for example for example I just use that response first this is the response and then we have to use that validation method previously what we have done like we have to use like this way but this time it will not any use because this see I just specify uh telling okay we this parameter actually we required in this Constructor so what I can do whatever Constructor I have uh the same Constructor uh same variable I can just pass it over here and that's it rest of things we will keep is a remain things right so let me copy the whole code rest of things which is the common right again just check okay make it first as a async so this is async and now see uh simple again just check the validation if it is validations fine or not if it is fine that is good if it is not fine just store and then return back and then if it is fine then it is going to inside that and again here what I'm trying to do just slightly different implementation what we have done for you know updation part that is a that is a way actually we have used so in this request I have to use I have to just pass that ID and I will use that blog repository. get by ID which will return your blog entity right so now we have a Blog entity and in this blog ENT so whatever blog entity and our request entity right request command so that we have to tr to match and if it is updated so we have to update so like this way we have to use this uh this mechanism actually to imer imer provide this this me imer do map and pass your whatever your you know request so this is your request and whatever Source you have to trying to update so you just pass to your source so I just first I'm trying to get our entity whatever exists so I'm getting this suppose I getting the three and whatever data and then whatever data we have so they just you know TR to update and once you update so they will just pass it to updated data over here and then update our entity that's it so this is done and rest of things is common like cash expression and return back over here so update also done let me quickly uh edit our endpoint as well go to the that blog endpoint uh blog uh blog controller and here uh I will just add our uh expose our endpoint put that update now see this is a put end point HTTP put passing that ID and this ID we have to just passing over here as a command ID and then whatever ID uh whatever data we want to update so we have to just use that update property and pass that update data and then simply return back to over here and let's see in actions now I have just newly uh this guy so whatever data I just let me check first and and there is a debug mode so let me quickly remove the debug first yeah delete all breako right and then continue now I have the data I want to update you know this one like four right so go to that update one and first of all let me uh just just add something suppose zero right I'm just trying to update so let's see what happened now see it is clearly saying ID does not exist right because the zero and whatever ID is not exist that will not exist and then when I add that existing data and just change it to something for example F let me add that id4 just whatever data we was previously it was like you know clean architecture now change it to update end point using clean architecture right and then just update the something description for that and just execute once you execute now I'm getting this successful result true and if I want to check whatever is the data is uh we have updated that is properly updated or not now see it is properly updated right whatever I updated this is updated that means our update feature also working perfectly with this validation and all right so now last things we have to implement in this here uh the delete one right so let me quickly close and just start for delete one so go to your application layer right so in here uh go to that command and let me create a delete delete blog folder right so let me quickly create that delete blog and here the delete blog I just create a First Command as like we have done already so let me create that guy and here again just create a public right and also we have to just require you know that ID so we can just inherit that the a base command command query and then we have to require response right so let me quickly create a response go to here create a response and then create a response and in this response what I'm trying to do simply I just using that base response nothing we have to do over here because we just simply pass through or false if it is Success then true if it is not success then false so also bring that name space that is done now go back to here command and also uh we can just use that iquest uh mapper to map that you know response that's it Now command is ready now uh go back to Handler implementation so here I'll just create a Handler class to implement that Handler so let me create a Handler make it public and this public also just inherit know that I request and all uh response and request right so also we have to bring back to implementation same things we have to doing our here so so again we have to do uh now just uh we have to just create those things right over here injected our services like whatever repository mapper and logger right so once it's done again I have to do same things for manually domain dot entity dot blog and here just adding for this guy okay so that's also done now we are good to go to implementation right so before implementation again we have to require some validation right so let me create uh validation also first uh create that validation one and in this validation again we have to check know same things for here uh to exist or not because before that we have to require to check that uh data exist or not and uh the ID is over there or not right so first let me check uh whatever so let me add first abstraction and Command right that is I'm missing so yeah so you can just use that abstraction and missing and then create a Constructor create a Constructor inside that we have to use this guy so yeah first rules I just set it over here which will check okay ID should be you know greater than zero right and then second rules again we have to do uh if is exist or not right so that we have to check so what I can do similar things I have to do that over here uh let me create a function and then also we have to inject it over here so that uh we can we can use is that okay so also we have to do that entity dot blog right and then injected this guy now injected also done now we are good to go to use this method and then finally we have to set that rules okay ID should persist or not or exist or not right so now we are good now validation part also completed for the delete features so this is done now go to your Handler and here I can just simply uh Implement right whatever our things we can Implement our create here our no uh Delete blog response so let me change it to through delete delete blog response right and then what I can do uh rest of things again we have to do same right so using the tri catch block and inside that I can just do same thing first the validations and then other things right so also let me yeah so like that actually we can do that first we to check this this guy but yeah uh we have to just change the variable name because we have to create a new variable name over here so let me change the variable name all the place and that's it right so now see again it is delete also the same way like okay first we have to check is there any validation error if it is not then go to here just you know call that you know get by ID end point first and in this get by ID we will return that blog entity and whatever blog entity we just call that you know the delete asnc method this is calling in a gentic repository and they will taken care everything and then return back to our response that's it now our this things also has been done let me build again so this is also succeed right so let me quickly add that blog endpoint right so which will just expose a new endpoint for that delete and this is also pretty much clean shape for this here for example simply accept that ID for the delete and then I have to just create a create a you know delete command block command and then passes to ID and then they will taken care everything and then return back to result and then simply response so let me run and see in actions so everything now we will test for that insert update delete get and get by ID so now first I will just check the delete one so whatever ID we have suppose we have a u nine but that is does not exist so what I trying to do so see validation happening and if I exist any ID for example whatever ID we have just added right last time so that is four so let me execute now see it is true that means it is delete and if I just check it over here now see four has been gone now if I want to up delete the three one three ID if I just execute three the three also gone let me check this guy now see three also gone now we have only two blocks so like that we can just Implement a for this block features with this you know generic repository but yeah now we will start uh that another features right that is author feature but this author feature we will use the extendable repository so how we can do that right that is important because this is I just creating as a template skeleton um clean architecture is skeleton so that everybody can use uh with their own prospective right so only just they will just just use that skeleton and they can just change your Entity framework or the DB set and they can just create your own feature and they can Implement yourself right so that's why I just creating this guys so what I can do so collapse that so now we have to implement our author right so before Implement that author what I can do I have to just you know create you know that extension method so I just have to create you know one another contract for that author uh so let me create that first so in this case I have to just create know one author repository over here is a contract so let me create that guy not a class I have to just use the interface use that I author repository and it should be internally should be public right so made it public and what I will do in here I will use use whatever existing you know feature of that generic repository right so that I will use that for example I repository whatever you know Common feature right so that I have to use in this this repository and also we will use the extendable method over here so that is called an extendable repository so what I can do I just simply use this guy then I depository and use that author right because I just trying to implement the author implementation over here and then here I additionally what I want I just want additionally method so now we have that all that predefined method right which is a generic method and but additionally what I want I want get by name if I pass the name so the author will be written as a list right so that actually we have to trying to use the additionally so that is called actually extendable repository right which have the same feature it's a common feature but additionally if you want your own features right so that is called so that is done now author repository has been created now what I need to do I need to implementation this author repository over there so before implementation first what I will do simply I can use this two our create first feature so let me go to here right click over here and create a new folder same way we have to do that in this author feature first is a commands and then second one is query so whatever command we have to create inside this command folder and whatever query things we have to create inside this query right so let me create a query so let me create a query right and inside this query what I will do I simply I just creating that features what is my feature my feature would be uh get authors by name right so whatever authors by the name I want to find it right so that I will create so let me quickly create a query for that features so right click on that right click add and new class inside that I will just create an get authors by the name query and make it public first it just make it public and here I have to require another response for that right so let me create a response whatever response I want to return so let me go to that feature create another response for that and in this response what I am to trying to return I have to just simply again call That Base response right and this is my base response make it public and here I just simply return to I know list of authors so I don't have an author dto so quickly let me create a author dto that could be a common for all the featur so I will just keep it uh inside this folder right so let me create that guy in this feature folder author class and in this author class same things we have to do that what we have to do for blog dto right so let me use that base dto because we have to record that ID right and in this ID and what is the author we have to reord property we requir know few property for example as of now we have as a name and email right so now go back to here this query right so in this query uh in this response actually so sorry we have to go to the response because we have to try to create a response so in this response what we are trying to do we have to just want to re return our uh list of resp author dto right or author so what I can do I just simply create a uh property which will return authors which is which is a list of that author dto right which is just created now go back to your command uh sorry query and here I have to uh just inherit I request and uh query right uh response so I request whatever response which we have to create it so this is done now also what we have to do additionally we have to reord one parameter right which will accept that you know name and all right what one name they are passing so we have to just create a name property in this query class and save it and now we have to good to go to create a query now what I can do now additionally we have to create that Handler now go to go to that know feature add a new class and create a Handler let me create a Handler again same things we have to follow make it public and also whatever uh request and response we have so I just pass it to I request Handler using inherit over here and then bring back to or just Implement that one so once I done now here same things we have to do as like we have done but here here we have to do slightly different so that's why I just create everything from that here so I have just to create a Constructor and then in this Constructor what I am trying to do I just inject uh our repository right so this is my repos itory this is a contract right I author author author repository and here I just injected this guy and create a property and assign to the Constructor right now we are good to go to use this guy and in this guy see I'll show you one thing in this repository dot now see I have everything delete update get all and additionally those method as well right so which will extend will we have to create it right so get name so like that actually we can create extendable repository and we can use it over here so this is done but rest of things we have to remaining same like for example our mediator r or other things right so that let me add it over here IM mapper and then uh logger things right so let me uh let me also created a assign a variable inside this Constructor and loger things also will be do the same right so yeah that is same now uh we have good to go to injected over here and now we have to implement right so same way we have to trying to implement but yeah before implementation again we have to record for this feature also as a validator so let me quickly create a validator a class let me add that validator class and this is my validator class and make it to public first and then in this here what we try to validate we are not trying to do anything but yeah we can just create a Constructor and then make it to uh abstract and all right so that we have to abstract abstract validator and whatever our queries so get author uh query right so this is our query so whatever your validation we required so we can keep it now and we can continue but as of now don't have anything so let me go back to our Handler and here simply create a two object right first of that our response and then validator and rest of things again we have to remaining same like inside this TR CR block we have to do that taking care rest of things like validations and then once is validations clear and let me add this a sync so yeah let me check then validations again if it is validation okay then go to that in this section and in this section see simply using that uh author repository call that method name and pass it to whatever name parameter and they will return back and then again we just simply whatever whatever response we just trying to map over here but yeah one more thing actually we have to do see uh now again we have to trying to map uh this entity author entity to author dto right so we have not specify right so same things we have to specify uh for this if you go to that uh mapping profile right so so idea is again so see if you're trying to do again uh if you new entity mapping in your things like suppose previously we have done for this blog D to blog right so now we have to try to uh what we have to trying to implement new feature that is call Author to author dto right so that we have to specify neither you will get the uh will that get that error so let me use reverse as well right save it so now they also as a common property so I will not doing anything so yeah but yeah if it different so you can use this way and you can just mention so like that also it is done author we set this author and response back to over here right so this is done also let me quickly uh add a Blog endpoint right uh not a Blog and let me create another controller because it is a new feature so I will just create a new apis and add it and just call it to author author and in this author what I will do simply I will remove this guy API uh controller base right and this once you inject it then I have to just use uh that mediator R right and then we are good to go to create our uh expose things so let me create first our sttp get which will return uh which will accept that as a name right and same things we have to just call over here right let me create endpoint and which will return and get authors by name response which we have to create it and just accept this parameter which will coming from here and then using that query and passing that name and then return back to result and return back to over here like that right so this way uh we can just uh we can just create and call that an extendable repository and let me run actually there is a one issue so I will show you what is the issue while running this application so let me run now see this is one issue I I knew it actually so I have not fixed because I want to show you so that if you trying to use this as as a skeleton so definitely uh you will face this issue so you have to know like okay how we can fix that so see what they telling like see I'm just using whatever that new uh implementation right for example uh I have just used I I authorized repository right so that I have not actually that specify or I know resolve the dependencies so that's why actually it is complaining right so how we can fix that let me quickly stop that and go to that your infrastructure layer go to your infrastructure layer now see first of things actually I have not specify over here and then second thing I also have not implementation right so whatever actually I just created contract right so if you see over here uh in this contract right where is see this is I just create a contract but I have not implementation but in this implementation of features so this is actually beauty of clean architecture as well like see this is a beauty like once you create a you know your you know your contract so you are ready to start your your features you will not prevent okay so you have not complete your outer layer so that is part of job of outer layer where is infrastructure layer so let me quickly uh let me quickly Implement that outer layer or non infrastructure layer uh that author uh authorize auor repository right so create over here and here what I will do let me create that author repository and here make it to public and then what I can do simply you have to uh use you have to inherit that your implementation depository as well right so this is your implementation depository you have to pause whatever your author um entity so my entity is a author and then whatever your um contract in author contact so I use that author repository contact now see so why I'm trying to do that like see this is a base entity right uh base repository and if you go back to our contract uh where is my contract so here my contract right so see here contract I just use inherit this I reposit right because because we required some common functionality so that's why I using that implementation as well and whatever they you know implementation they will taken care over here and then additionally we have to use that I uh repository they will Implement over here like see Implement and so only we have to takeen care implementation this guy right and see one more thing actually they asking so see it is required some you know uh context right because if you're using this guy so if you go to this guy so they expect this base repository because we using so definitely whatever base uh Contra uh Constructor so they will require actually that blog entity right so that we have to add it over here so how we can do that it is simple what I can do simply just create a Constructor right and here I just use our know blog whatever you know so let me add that blog and then use that context right it is a Blog context let me make it that block context and then I have to just use that base Constructor because we pass it as a base Constructor and pass this guy simple right so like this way we can just use as a here and we can call it right so that is done now we have to go to go to implement over here using that uh whatever using that base conu right so now uh we are good to use that guys so let me check blog blog DB right it is not available so what I can do this is a one issue so go to again the base repository right and here I just make it to private so instead of private we we can just use the internal so that I can use as a internal right we don't need to expose to public so here now see I'm I'm good to go to use that and then use that authors and then use the V conditions and here use that Lambda expression to use name and then here we check okay whatever contains right so contains if contain that name they will just compare and then return back to here right and this is returning is iable so what I can do simply I just make it to list right to list and also you can just make it to list a sync as well so that it's good and make it a weit and using a sync and then simply return over here now see this is good implementation also done now we are good to go to use this extendable method with the extendable repository and we can implementation done so now once our implementation done we have to do uh registration as well uh resolve the dependency so go to that infrastructure layer here we have to resolve that dependency add transient right and here I will use that I repository author repository and what is that implementation here then author repository so this is this is done right so now we are good to go let me build it and let me run it now uh our ready over here also so now if i l so it will should be not work so let me pass something T and now see if it is related to T so it will returning that author it is K also returning so as of now we have now see two blocks so whatever it is related to and K so whatever contain so they will returning back so now this way actually also you can use extendable and one last thing actually we have to do over here so that is called uh so see this I just created a extendable uh method right so that I have to use but if I want uh that inv one right whatever genic uh repository method provide right like add update delete one right so that also I will show you uh one last things over here so let me create a command over here for that implementation that way uh that things right so let me quickly create that method over here in this command so let me create a command for that that is called okay let me first up stop and let me rename it and then add it that okay create author right and inside this create author what I have to create I have to just create a one command so that I can you know create a new author so that I will just use without creating any additional method and all so let me quickly create uh this guy create author command and here make it public first right and in this create a command what I can do I have to just request that response first okay and before response I just required you know that input uh value right that is called author d right based on the author D I can just you know use that guy and then reord that uh response so go to here and right click on that here and go to that and then create a response and then response let me quickly create that and what is that response would be over here return type it is simple we have to return that U you know author ID right so let me create a author ID and call it that base response base response that's it right so the response also has been created now we have to use I request Handler I request only and then use that command and now we are good to go to create our uh Handler so go to the create our Handler quickly and then create that Handler and inside this Handler again what I need to do simply uh inherit the two things that response and uh command command and response so let me in and just Implement right and then Implement and here what I can do again I just uh you know create a Constructor and inject all the things what we have done in previously right same things we have to do that so instead of creating again simply I would do I'll just copy over here and paste it like that so see what I'm trying to do simply just inherit uh injected that I author repository right that is a extendable repository and then mapper and then logger which is the common for everywhere right and then here uh we already uh we have not create actually validator right so that validation class also we have to create it first so create that validator over here let me quickly and in this validator what I can do simply I have to validate okay whatever input property and all that it should be uh first they have to just should have value and all right so let me inherit that abstract validator and create command and then inside that create a Constructor uh create a con Constructor and in this Constructor I just I have to just check this two rules right so first of just I'll check the name and that email that should have value it should not be null and empty right that is done now go back to your Handler and here I'm good to go to implementation over here right so let me again just uh start with that creating two object for of that create author object and validator and rest of things is a common right so let me copy that because I'm not going to do because it is a repetition thing so this is fine and also what I will do a sync right and then it is see again just validation part it is a validation part so it is just covering validation whatever validation they will storing if is there issue so they will just return back and then uh if it is no issue so then what we will do simply again see this is a mapping part which already we have mapped right and we can just remove this guy we don't requir over here so we have to just convert as a author right so let me create a author uh okay so this is author and again so this author actually we have to bring back that name space again so let me add that domain do n entity dot author right so let me add this author so this is entity right we have to try to map with the dto so whatever D we have to convert to author and then we get that entity and then simply using that author repository do add sync right so see this is add a sync this is expect this is accept actually expect actually the author entity right so that's why we have trying to conversion over here so like this way we have to do and simply whatever result we are getting we pass to author and that exception things and then return back to that right so like that actually we can Implement and now see there's a one issue it is saying completely saying we are doing something mistake right so see uh what is the mistake it is expecting the T as a command and then uh know response as a response right so we are missing if you go to that command go to author command see by mistakely we have added that command but here should be as a response so let me create author response just assign to author response that is fine and then go back to here now see error has been gone so that I have to takeen care like see that command you have to just specify response and then in this Handler you have to just specify command and response both together right so like that actually we have to do and now our feature has been ready now what I will do just simply I have to just create a u author controller and here have to just expose in one method right so one end point so that is called you know create uh Handler uh create author so here see I just simply expose that create response right which is a return type and passing the author dto which will accept that whatever uh parameter and then here I just pass that command and then result and return back over here right and save it and run it now see uh we have that author and blogs right so now check that guy right let me create a new author for example uh new author right and email is new at theate gmail.com and execute once you execute now I'm getting that id4 right and then if I check over here uh as of now what I just add is new author right so let me check over here now see I'm getting that new author right so it is perfectly fine now it's completed right implementation of what we have done so that is complete our that clean architecture skeleton so this is actually the beauty of the clean architecture what we have done now it is a good things right so if you want to implement a new project as a clean architecture so simply you can take it this template right and you just use you just you know just Implement your you know just change your infrastructure layer whatever your context and all right so you can just change it and just Implement your features or you can ready to go to use right so that's why actually that's way actually we have to use uh we have to we I just created for this right so this is enough for this session right and uh I also will be just push this uh now repository so you can take it uh from my GitHub link right if required but yeah I'm especially recommend don't just don't take it that as the first like just just first create yourself first whatever things we have to done in this one or two hours right so just take spend the one or two hours and create yourself in first time so definitely you will get that more idea like what is that exactly we have doing with that clean architecture right so that's why I will suggest let's instead of just copy paste let's first of you have to create it right which is very important as a for the developer right so that is done so before closing this session uh clean architecture is Clon session so first I what I will do I will just add uh the my repository so that you can use this as a reposit as a skeleton and use it and make it your life easy uh this is the name of that Klean architecture demo in my GitHub link so you can just take it as a reference and you can use it but yeah um I'm I especially recommend before taking this one just try first like whatever step I follow in this session so everything you have to just follow one and then if you get an challenges and then then you can take it here so let me create and push so now it is available on our GitHub link you can take it and that's all for this session thank you have a nice day and don't forget to like like subscribe and share
Info
Channel: DotNet Real world example
Views: 718
Rating: undefined out of 5
Keywords: Clean architecture skeleton, Clean architecture, implement Clean architecture skeleton, how to implement Clean architecture, how to implement Clean architecture skeleton, Clean Architecture Skeleton Tutorial, Implementing Clean Architecture Basics, Creating a Clean Architecture Skeleton, onion architecture, data clean room architecture, c# clean architecture, net clean architecture, clean architecture diagram, net core clean architecture, clean architecture c#
Id: N6cyzeSGlw8
Channel Id: undefined
Length: 166min 44sec (10004 seconds)
Published: Sat Apr 20 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.