CRUD with a .NET 6 Web API & Entity Framework Core 🚀 Full Course

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and welcome dotnet 6 and visual studio 2022 is now available and what is a better time to test this already and build a net 6 web api so i would say we'll do this together now i didn't really have a look into it just a tiny glimpse so i have no script nothing at all so i would say we just start but first if you like this video and you learned something i would really appreciate it if you click the like button maybe even subscribe to my channel really appreciate that maybe you also want to subscribe to my newsletter i promise i won't spam you maybe i write an email once a month but with that you will get more information deep information about upcoming youtube videos online courses and so on and thank you so much to everybody buying me some coffee it just tastes tastes so great and um yeah helps me to stay awake when my little boy is asleep and then i can make all these videos all right anyways let's start visual studio you can see it here visual studio 2022 it's just maybe a week here 10 days i think 10 days now that we got this new ide and we start by creating a new project and you can see it here i just tested this a little bit of course we can create blazer web apps i really love blazer so i do this a lot and then here we've got this template asp.net core web api so if you only want to create a simple web api maybe you can look for web api and here it is it's still called core so this name is still used internally a project template for creating an asp.net core application with an example controller for a restful http service this is what we want to do let's test this well i like superheroes so hero api and the rest is okay i guess dot net six this is the one we want we configured this for http that's nice we could also enable docker but we don't need that yes we use controllers we will not use the new minimal api but we will also enable open api support so with that we get swagger support and can already test our web api all right let's create this thing and as almost always we get an example application here also with blazer for instance we also get the weather forecast model here so this is used to demonstrate the web api we've got our controllers already so this is the weather forecast controller here and we also get a get method i think important is here the launch settings json as well so with that we see this profile superhero api and when we start the app then you can see the profile superhero api and when we click here we started with debugging but i don't want that now i want to start this without debugging and then it will go to this url here https localhost 727 is the port and the launch url swagger so we already get access to the sweger ui so we can test the api directly and what else we've got the app settings json for now not interesting and this is now really new in.6 instead of net 5 we only get the program cs file here not the startup cs anymore this thing is gone so we only have the program c program cs and also interesting here we've had we have no name space the curly braces are gone somehow and we do not have the configure services method and the configure method everything is now done in here in the program cs all right that's okay and of course it helps building minimal apis because when you want to build a minimal api if you want me to make a video about that please tell me that in the comments then you would add all your methods here in the program cs well at least you can do that but we don't we will kind of build a typical web api old school i know but as you can see here we register some services at controllers this thing here is necessary for swagger here then our app is built and also here only in development mode we will use swagger for our api okay then we have https redirection that's great authorization all that already there and then in the end app run that's nice again we've got our model here the weather forecast consists of a date temperature temperature celsius and fahrenheit and the summary and the controller now this thing of course is interesting if you're absolutely new to web api controllers let me go through this real quick we inherit from controller base as it says here a base class for an mbc controller without view support we don't need view support if we wanted to get view support we can inherit from controller that's that and when we have a look here i'm trying yeah i press control and then the left mouse button with that we get a bunch of stuff here we get the actual http request here the response very important sometimes when we use authentication the user here with the claims principle with that we can read the claims and the roles and so on and all the stuff you want to return like an ok result for instance this would be then the status code 200 and so on so lots of stuff and then also important are these two attributes with the api controller this thing indicates that the type and all draft types are used to serve http api responses so we want to use a controller here and this is what we have to do and down here and then the route specifies an attribute route on the controller now what you can see here in these brackets this is a convention and this means that the route will be the name of the controller so everything that comes before controller so weather forecast and then we've got some [Music] summaries okay a list an area of summaries we've got the log i won't dive into that here but we also get a constructor where you can already see dependency injection in action so the logger here is injected and there's also a private field created for that well let's forget that for a moment for a moment because the important part now or the really interesting part now is already this get method here and as you can see we use this http get attribute you don't have to use it but for schreger you do have to use it meaning if you create a method called get anything so get weather forecasts get the weather get whatever get the superheroes we will build that in a second and then the web api knows that this is a get method meaning that we wanted to use the http request method gets all right so this is important but if you want to see a documentation an api documentation with the help of swagger then you would need to declare this as http get so let's use the attribute here and then well this is the logic of the controller method in essence we're creating random weather forecasts and return them all right so this is an overview i'd say of this example application and we can already run this and chrome starts great and we already see swagger here these are the schemas meaning this is our model we have seen and this is our get method here so we can open it we can see an example value and this is also yeah that's crucial here this is important to point out we can only see the example value because we we're telling this function that it returns an i innumerable of weather forecasts and with this weather forecast then uh with this model uh swagger knows what to expect here and then we can also display the the schema here all right and then we can already try it out and hit execute you see this is the the url here and we get five forecasts back from the service all right now it's important to mention that name here does not mean that this is the route of this function when we remove this trying to remove it and save this and maybe restart the application here did another video about the hot reloads which is not always working as expected i know i know i have to rebuild the app here this is totally fine but uh you know just as on a side note b4 with dotn5 and the dotnet watch command if you started your app from the cli then it would rebuild your application by itself and here now we have to do it by ourselves so it does not always work automatically but still i think this is rebuilt and we have the same method here but we can also give this thing a round meaning we've got this attribute here as well remember this is also mentioned here above the controller class and here we can call this i don't know let's just call this weather and then the route is different oh it rebuilds okay it's nice forget what i said everything works perfect and so this is not the new route and do you you do not have to use two routes here or two attributes here we can also put this thing up here and this also works okay to see the change let's call it weather1 great okay this is amazing hot reload at its best and you can see we can try this out hit execute and it works all right so this is the example application and now let's build a superhero api let me just take a zip with my coffee jesus my voice is i'm losing my voice all right thanks for the coffee okay let's first create a new model i'd say so right click the project and then add a new class and that'll be our superhero there it is okay my machine is kind of slow today and let's add some properties now if you're wondering what are these purple lines here this simply means hot reload does not work with that we have to restart the application and again that's totally fine this is how it worked before with dot net five so let's do that again with dot net six um we had some properties maybe an id also let's add a name which is string empty you see the great intelli code here this is amazing suggesting some stuff and also then the first name [Music] also string empty and another string which would be the last name string empty and let's also add a place could be place of birth i don't know or where they live now yeah almost all right a place let's call this place okay let's save that now you can see it here now the hot reload i activated how to reload on save on file save and now it's telling us that we have to rebuild the application that's correct and for this session in visual studio 2020 new we can just remember that we want to rebuild our app with all the changes when we change something and how to reload itself is not working so the big difference in essence is with hot reload you don't have to rebuild and restart or reload your application you can just stay on the same page and magically the page changes as we just saw with swagger we saw the the changing url changing route but with that we added a new model so this is a root edit this is the proper term i guess the root edit we are really root developers so we have to rebuild our application okay anyways we've got our superhero here nothing should change here we do not see the schema swagger has no idea what's going on for now but now we will create a new controller right click add and then not a new item simply hit controller and please go to api here and then we got three options the api controller with actions using energy framework not so fast not entity framework yet not even read write actions in my opinion then you would already get the code for the get post put and delete http request methods that we will use here but i would say for learning purposes and even if you know this stuff already i prefer building an empty controller let's click add and then we give this thing a name superhero controller build it and there we are you can see the route now is a bit different that's totally up to you do you want to use the api string or not i like it that way i know that that's the api and apart from that we also see the api controller attribute and the controller base class here and that's everything so now if you need a constructor you have to build your constructor your get methods and so on now when we save this it is already saved it's rebuilt nothing changes here but now let's add a get method so right away we add the attribute http get and now i want to create an asynchronous method so a public async task and you see the suggest suggestion here already i like this word a real tongue twister tongue twister tongue twister yeah i think it's tongue twister and it is returning an action result this is different right it is an iaction result and what what is an i action result defines a contract that represents the result of an action method now you know right well let's create something here for now with the get method we will return a list of superheroes so let's create this here really quick new list of superhero that and maybe we can use the object initializer to already add a new hero here so new super hero i want nice name would be what's your favorite hero come on write it down in the comments i really like this guy and with that we've got peter and then also and the place i guess is new york city and maybe we can format this a bit differently let's put this in new lines come on this is still not working this is a shame ctrl k d also not working alt shift and f not working okay then let's do this by ourselves and yeah now we've got a list with one superhero and here now we return not the heroes we return okay and then the heroes like that and with that we are returning a status code 200 which means you can read it here status 200 okay this means everything went fine if something went wrong we can change the status code for instance we can also send a bad request and this would result in a 300 no 400 sorry and this is a 400 and what about the one that everybody knows even the people that don't write code 404 not found for instance so these are the status codes and with this information of course the client can do something but in here now we simply return okay heroes that's that and i would say let's test this already we hit control s and here is our new api this superhero api but as you can see it's not appearing here in the schemas now why is that when we open the superhero here we don't see any example values well that's because of the return type it's just a generic i action result now if you want to see the uh the model in the swagger ui then you have to change that and instead of just returning the interface here or using the interface we return an action result and give this action result also a type and this would be a list of superheroes like that and we save that now and [Music] we've got some errors here yes the last angle bracket was missing okay now save this thing rebuild it and now you can see this is our model we see an example value nice we can try this hit execute and voila there's spider-man isn't that nice this is so great almost how what time was that 20 minute okay 20 minutes because i talk too much but i mean you can build this in five minutes dotnet six videos to do 20 22 five minutes and you're done with your first web api get call all right and now the next thing would be the post call meaning creating a superhero now before we do that let's move our heroes here cut them and put them here on top of our controller and let's make this a private static list of super heroes so that we have access to them from everywhere that's the correct syntax here all right so now with that again we can save this of course and have a quick look in swagger this should still work we open the method and then try it out and there we are and now post so creating a new superhero by the way short side note maybe if you already want to dive really deep with a web api and net six and entity framework secret server relationships and so on then maybe you want to check out the video description below there's a link to the jumpstart course or maybe even better you may want to subscribe to the newsletter where i will tell you right in your inbox when i start my own course platform where you get access to all my courses for a fraction of the price so just as a side note if you want to be the first to know when this thing goes live then maybe subscribe to my newsletter and then you will get access to it okay now with that a little commercial out of the way let's create a post method it looks almost the same so let's say we want to use the post http request method now for that we use the http post attribute here and then let's copy this and what we will return again is the list of superheroes because i want to return all the superheroes then but we call this now let's say add hero name doesn't really matter in this case because we defined the attribute here but this thing now gets a request object and well let's use a superhero let's just call it hero and here now since we got our hero list in the so in the controller we do exactly that what is suggested here by intellicode now heroes add hero and in the end we return the hero this should already be it of course there are some details like the route you can change the route and we have to change it if we have more post methods here in this controller and also what we could do is add this little attribute here from body but since we're using a complex type here in the parameter it's not an integer not a string and then we don't need this because our web api will assume that this object comes within the request body anyways so this is totally fine we save this and let's go to swagger now there it is already again hot reload at its best we see the post method and here you can also see the example value we can so the example value for the request that's important you see the request body here and again this is the same object in essence and here is then the result example let's try this out and this is the nice thing of swagger one of the nice things it already suggests a request body here so we see id0 the name and so on so yeah in essence we can just use this hit execute and you're getting an error object reference not set to an instance of an object okay let's see i don't know what's wrong here but as i already mentioned in my other hot reload video could be the case that we have to restart the app manually not sure why but it's restarted now try it out execute and now it works of course the id is nonsense here id 0 in this case the strings and so on but you see that this works now and just for fun let's use a real hero now id2 name would be iron man for instance tony stark and the place is a long island just hit execute and there now we've got the three heroes what happens if we reload this this is the post method we get the fourth one but of course when we restart the application the heroes are gone we do not store this persistently in a database so when we now get our heroes it's only spider-man now okay so sorry for the confusion that's really important to know with the new hot reload sometimes it does not really recognize all the changes it shows you an error where there is no error it told us that there's a no reference exception i don't know maybe it will it did not see the list here i have no idea what was going on all right now anyways this is the post method now what we can also do is we can before we add a put and delete get a single hero so we can do the following just add tony stark here so that he is available all the time with id 2 and we add tony stark this is jesus this is iron man of course tony stark and then he lives on long island formating does not work again but still now we've got two heroes and now let's say we want to get a single month so not all the heroes but a single run single one so we again add a get method here return type is now only one superhero and we can also call this get but we will add an id as a parameter it's going on here of course nope close this now it works and we return now heroes or let's try something else we can now say our hero is from heroes yeah why not with this id here or we use the find method we can also do this where we just say with the lambda expression the hero with the given id but i think with the fight method we can also just do it like that no doesn't okay so let's do it like that and then if the hero is null in this case we really return a bad request and we can also send a message with that for instance hero not found but otherwise if we find the hero we simply return it god yeah jesus all right and now we are not done with that we have a parameter here and we have to add it here in the route as well and we can simply do it like that with the curly braces this is the parameter now should be the same name id and id and now this works there's our new method superhero this is the example result we can try this let's add one for instance and we get spider-man perfect let's add id2 hit execute hero not found this is interesting because we added id2 here let's restart the app again manually there it is and now we get tony stark see we have to restart our app sometimes but now this is what i wanted to show you with id3 now we get the response status 400 it's a bad request and we get the message hero not found and if we want to get all our heroes try this out hit execute we get both of them all right great so this works we can add heroes we can get all the heroes we can get a single hero and now let's change the hero for instance and for that this is an http put and i am really lazy so i copy this again now the thing is we can do it both ways either we just accept that we use a super hero object as a parameter let's change that to update hero and we grab the id then from this object and search for the specific hero in our list or we can also add a second parameter with the id up to you how you want to do it let's do it like that in this case and yeah return the complete list again so first we try to find it and this is why we can copy this thing here and actually you can also copy this let's make this really quick and dirty so this is our hero let's call this request maybe and then we look at the requests id so this is the first thing and this is then the hero we've got from our list but now we want to overwrite the properties right and we have to do this by ourselves there are options to do it in another way for instance you can use auto mapper and define one time how the updating would work but in this quick quick quick really quick course or tutorial let's just overwrite this manually we do not overwrite the id of course so what we can do now is here we say the the name of the hero for instance is now the request name the first name first name is this first and last name is the last name and the place is the place okay so this is what we want to do actually in our list we want to change all these properties and in the end we return our heroes so let's save that just to be sure let's just restart our app there's our put method try it out and now let's say i wanna call a spider-man amazing spider-man like that now the bad thing is that first name last name and place would be overwritten as well let's just leave it at that that's not in the database of course so we hit execute and there's our result you see amazing spider-man is now called string string and he lives in string so this is the put method i guess this already works of course when we do this with entity framework in a database we have to change this a little bit we have to make the call to the database get the hero make the changes and then save them back to the database but in essence it looks quite similar all right and now the last thing already is the deletes for that we use http delete again we can copy and let's copy this thing here and i forgot the parameter so http delete with the id we call this delete and we return a list of super and again we find the hero if it's not available then we display this message here but otherwise we say heroes remove [Music] hero and then in the end we return all our heroes and again we restart this thing there we are and you can see here maybe i did not mention this these are the http request methods here get post put and delete and with the put for instance when we when we call this thing when we try this and hit execute you can see here also with the curl statement here that the put method is really used and the request url is this thing here now we get a hero not found this is great because we haven't tested this yet but now let's try to delete a hero what about id3 first there it is hero not found great that's what i wanted and now let's remove tony stark it executes this is the response body so this is not correct where do we get the zero back oh i returned the hero okay that's wrong of course so let's try that again rebuild it we have all our heroes i hope yep that's correct and now here let's try this execute and now only spider-man is left and of course here when we get all our heroes it's the same results all right and that is it this is how you do this this is how you implement the first four controller or five calls in your web api controller we've got the get by id in essence where we get a single hero we've got to get for all the heroes add all the here add a hero with post update with put and delete it again with well http delete all right and you know what because i'm in a very good mood i would say we also add entity framework now with the sql server database now how would this work we need a data context for that so let's do that real quick again i go much deeper and explain more in the the course but maybe if you just want to to get started here and and you know you're looking for tutorials or you don't want to read stuff and you don't have much time just keep watching and i think this will give you a good start regarding web api and now even entity framework with dot net 6 and visual studio 2022 so back to visual studio now the way i do this usually is i would add a new folder and by the way when i say how i do this usually in the course as well or in the courses where we use a couple of web apis you would not add the whole logic to the controllers here you would use services with the repository pattern where you would then add a constructor in the controller inject the service there and then this logic here to find the heroes update them and so on would be then in the services and but for now i think this is okay this is the first step in the web api so data now and here let's add a new class and we call this class the data context so this will be the context of our database and we have to inherit from a db a context and for that now we have to install the package microsoft entity framework core yep and additionally it's getting a bit more complicated now we have to add some more packages now to be absolutely sure yeah let's just stop the app from running so we just close this window here and then we manage our nuget packages and in here now we've got microsoft yeah there's already this the suggestion so entity frame record design we need this for our migration because we will now use code first migration surprise so let's install this thing and then we will use a sql server express database and for that we also need this package here entity framer core sql server that's the one install it okay i accept all right you see all the warnings here because we don't use asynchronous methods but we will do that when we use entity framework in a sec go away jesus okay now it's gone and now let's have a quick look in our project file here yeah entertainment core design and sql server everything is here this is the swashbuckle thing is for swagger and now we've got our data context first thing now is a connection string we have to add a connection string meaning this will be the string uh how we connect to our sql server database then if you you're wondering whoa whoa this is way too fast sql server i don't have sql server well i can help you out let's go to google and maybe search for sql server express and well this is the german link don't know why this is the one i was looking for try secret server and here express please download this thing and additionally you can also download the secret server management studio this is what i use there it is and here you can download this thing is a great tool to display your database of course we can do this as well with visual studio itself but um i just like it that way so with that out of the way let's add our connection string for that we add a new section here connection strings and now typically you would call the first connections connection string here the default connection and if you have installed sql server express it looks kind like that server and if you installed it locally then this would be server localhost sql express then we've got the database name let's call this super hero db maybe and then the last thing trusted connection true all right so this is now the connection string here low close sql express database superhero db and trusted connection set to true and with that we can work next step before we go to the data context here we have to install entity framework actually so to install nd framework well you can check if you have already installed it maybe it is so let's just enter in the package manager console by the way if it's not open you can get it from view other windows and then package manager console and then you enter.net ef and as you can see i've got antiframe record.net command line tools 6.0.0 installed if this is not the case for you then you simply do the following dot net tool install dash dash global and then dotnet dash ef so dot net tool install dash dash global global.net ef if you have an older version installed just use uninstall and then use install again and if i now hit return it's telling me it's already installed okay that's correct in your case maybe it's not and then you would see the actual uh version of a dodge net entry framework if you hit again.net ef all right so with that now out of the way we can finally move on with our data context so the data context again this is important maybe let's read this together real quick a dbcontext instance represents a session with the database and can be used to query and save instances of your entities the dbcontext is a combination of the unit of work and repository pattern so similar to the thing i already told you with the services that we will use in the courses we will use the repository pattern there this means we will see this in a second the superhero controller will inject this context here and then we are able to access the superheroes from the database but to be able to do this first we need a constructor here and this looks like that public data context and this thing gets a parameter of type db context options with our data context we call this options and we also have to use the base constructor here with our options so this is the constructor and then since we will use code first migration and we want to see a representation of our superheroes in the database we use or we have to add a db set this is a property so you can use the built-in snippet here prop hit tab twice and then this is the dbset of type superhero and we call this thing and this is the name of the table that we will see in the database usually you just pluralize the name of your model so we would add super heroes like that okay and that's it this is our data context but after that we also have to register this thing so we moved to our program cs before it was in the startup cs now it's here and maybe let's do this here before all the swagger stuff we write builder then services like that and then add db context we use our data context and of course we need a reference here using superhero api data and what we can already do this is also new new in c sharp 10 lots of new stuff actually we can make this a global using because maybe well not maybe we will need the data context in the superhero controller as well and maybe we don't want to add the using directive every single time we will add more controller services whatever so we can just define this globally and then we won't have to use or add another using directive in the superhero controller all right so builder services at db context and now this thing gets options and let's put this in a new line and in here now we configure our sql server or we tell this data context that we use the sql server so options and then this method here use almost use use sql server i need another reference here all right let's add this globally as well almost global and then configuration [Music] wait this was.net for five here we also need the builder now we got the configuration and from that get connection string and this would be our default connection one parenthesis is missing and add the semicolon and now this should be it all right so this is the configuration and now finally let's save everything make sure that the app is stopped because now we will use code first migration finally so let's clear the screen here and now we add this with or let me show you this one more time with dot net ef you see the version also the available commands database db context and migrations we need migrations for our migrations and also database to update the database then so let's use dot net ef migrations and then we add one and well the name then is up to you this is the initial migration so usually you would call this initial or create initial something like that hit return and there was no project found why is that well we have to be in the server directory so let's go to superhero api and then oh no jesus i am doing lots of stuff with uh blazer web assembly asp.asp.net core hosted this is already the correct um directory we are now in our project directory not the solution directory the actual project directory superhero api and now this should work so dot df migrations add create initial our entity framework is trying to build this or the net framework hope this works yep build succeeded and we've got a migration file there it is this is not important for us this is important for us we create the table see that this is our superheroes table we've got the id which is already the primary key here and this then is automatically increased when we add a new superhero we got the name first name last name place and so on so this is done in the up method and in the down method you would just drop this table and now we can use dotnet ef database updates notice we this is the update command even if we do not have the database yet it will create the database now so dotnet ef database update it is and then you will see what entity framework is going to do lots of stuff and where is it here you can see create database superherodb it creates a table you have migrations history this is just for entity framework not interesting for us at least for now and then here you can see create table super heroes and now let's open the sql server management studio there it is we connect to the database we open our databases blazer e-commerce is from my e-commerce course i'm currently recording but i thought this is also interesting with the superhero db for you guys on youtube so let's also open the tables here this is our table columns great and we can right click the table edit top 200 rows and we do not see any rows well this is sad of course but we can add a hero here as well so the name for instance should be again spider-man first name is peter last name parker and the place is new york or let's call this new york city and now we've got a superhero and now we want to get this hero here and not the mock heroes from our controller so let's change that real quick as already mentioned first we need a constructor so let's add it here with ctor and tab tab we can add it and then we inject the data context you see now it already knows the data context without adding the using directive and then we use control and period or you use the light bulb here this quick fix menu to create and design the field data context also i've got dimension here you see this underscore data context well let's call this context i think that's better this might not be the case for you this is what i have configured in your case you would see something like this this context and here the underscore would be gone i configured this with visual studio maybe i can show you real quick options and then a text editor c sharp code style formatting and here it's no not formatting it's naming that what that's what i was looking for and here you can configure this you can manage your naming styles and this is what i edit you can add simply one more i named this underscore field name the required prefix then is the underscore with camelcase name and with that then you can add a new one here so simply add click the plus button and then for all the private fields youtube you choose field name and then as a suggestion and then you're good to go okay that's that now we've got our context and now this is pretty simple instead of just returning our heroes here in the get method we return awaits and then context and with that we get access to our superheroes and that's already it we just add the two list async method here and we're done now we're getting the heroes from our database so let's start the application and there it is let's see call the get method try it out and we get the spiderman peter parker is here and you really see this um how can i prove this to you well let's remove this guy here simply and now try this again again we see spider-man great so that's that and now what about getting a single one to do that we again use our context and this is then superheroes find and again this should be it already but we have to use the async one and here we now only add the id so this is a different method now and this is where i tried to yeah you know i see i'm a bit confused myself this is how you get it with any framework so we access the contacts the superheroes and with find async now we just add the id and so it is looking for the primary key here that is equal to that given id here so again let's save this and i have some trust issues here so let's restart the app there we are get this one try it out now id2 shouldn't be available not found and what about id1 works great you see how fast this really is and now adding a hero almost the same we call contexts and then superheroes add hero and after that await context save changes async because with this ads method here we change something in our table in our database table and we have to save this change and that's what we call context safe changes async and with okay heroes that's not correct we want to return all our heroes so await context superheroes to list async then all right and then well let's just test this restart the app again let's do this again okay so post now we've got this thingy here let's have a quick look again in the database we only have spider-man so let's add tony stark now try this out id can be missing now tony stark jesus every time iron man tony stark and then long island execute and now we got two and let's have a quick look here right click execute sql there's iron man yeah this works this is nice and now real quick updating the hero again we can copy this actually so you know maybe we should refactor this but not today so this is our requests and here we want to get the request id and we can also call this db hero because now this is our database hero and we have to save these changes again so context uh wait a sec await context save changes async that's what i wanted so we set um yeah we again we overwrite everything in essence and then we return all our heroes again let's save this now let's just trust visual studio here we go back this is our put method but first let me get let me get the object so i don't have to type this again this is our spider-man and now in the put method i want to try this again our spider-man but now i want to call him amazing spider-man again and now it's important to to also send the id because this is how we get the hero and now let's just execute it and there it is this is amazing spider-man and when we have a look in the database there's amazing spider-man updated great so this worked as well and the last thing we have to do is the remove function or the delete function again we copy this here and paste it here all right and now we say context superheroes remove and then [Music] this would be our database hero again like that and after that again we say wait contact save chase changes async and we return this here all right and now we can finally also remove this thing okay save that this is the delete go to swagger and again we've got two heroes here iron man and spider-man and let's try to remove iron man now hit execute we only get spider-man back and the same for the database alright that's it let me just put this together push this to github so we create the get repository super hero api let's also call this dot net 6. yeah i think this is great we make this public then i create and push this and then we're done all right so this is it i hope you learned something and uh it's not so bad it wasn't so bad with all the arrows that happened i think it's it's great to see this sometimes if you liked it please give me a thumbs up thank you very much for that maybe consider subscribing to my channel really makes a difference thank you for that again if you want to dive deeper consider subscribing to my newsletter because something big is coming i've got some courses already if you can't wait just check them out or just check out my youtube channel there's also lots of content regarding.net and blazer and different stuff so maybe the newsletter and the last thing again thank you so much for buying me some coffee maybe you want to buy me some coffee too i love you guys it really helps making all these videos tastes even better with all your support okay again i hope this was some value for you thank you very much for watching and i hope you see you next time take care and happy coding [Music] [Music] [Music] you
Info
Channel: Patrick God
Views: 3,950
Rating: undefined out of 5
Keywords:
Id: Fbf_ua2t6v4
Channel Id: undefined
Length: 60min 38sec (3638 seconds)
Published: Tue Nov 23 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.