.NET EFCore | Quickly test your APIs with Visual Studio .http files (CRUD Operations)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
Hello friends welcome back to Netflix Channel   now in this video we are going to talk about  how to use HTTP file that is a new feature in   Visual Studio now what do we use this HTTP files  for so they are used to test our API so instead of   running the Swagger UI have another post method  I get method and other methods we can use this   HTTP file in it to test our API let's have a  look with this actually this is going to be a   short video so we don't want to waste time here  now we have to create a new project and that's   going to be a web API projects so lots of Visual  Studio then go to visual under the web API so   for c-sharp click on next one and I'm going to use  HTTP files project so on the location down keep it   let me choose a different location  or maybe this and click on nest   all right so I have 7.0 and 6.0 so let me choose  7.0 as the framework and I'll click on create   to get this project created now when this is  done we are going to apply the scaffolding   um to get a controller so let's right click   so let's create some models first  so I'm going to add a class to this and this class let's make it at user so this is a class you're  going to have maybe a name so let's say this user class we're  gonna have a name and maybe address   and location something like that let's see so  there's an end and that is going to be the ID   now the next one we're gonna have let's say name and the last one location so that is our model okay  so right click on this and you can go to uh and a new scaffolded item so we're  gonna choose API and now we want to   get all the action method using this EF call okay  so with this let's click on ADD and see we have to   install these packages first so let's choose  our user model and let's create a DB contest so that's our DB contest then we  have our server here SQL Server   you want to use this name for the controller  so let's click on ADD and as you can see it is   generating this code for us and as you can see  it is installing this package microsoft.visual   Studio dot web.codegeneration.design after that  it has to install all the required packages you   can see tools and SQL Server it has installed  them and before it can be used to generate our   um the scaffolding item so as you can  see it is now building the project   so let's read patiently for it now this  is going to create all the card operations   for us automatically so we need not to do it  yourself so that is a new way to improve your   the time spent creating your API so obviously  we have the get and that's also get by here is   get by ID and it's going to get all as  you can see I remember and now this is so put and that is going to be the update so  you're updating it and now if you check this   there's also the same thing let's put so let's  add the new item and that is a delete so we   have a hard operation here okay now with this you  can run this application to see what we have now   so we see Within some few minutes we are done with  the controller and model our contents everything   has been created and installed fast now you see  we are running in the browser and we have the   Swagger UI we have our Cloud operation here so we  can go for get try this out let's see let's see   the outcome of this so it is saying that cannot  open database yeah so you can't open this it   means you haven't performed database migration so  let's let's try that and see so let's stop this so this let's go to choose and you  get package ninja console migration let's say initial so let's wait to see if yeah  so done now let's update so update database so before we let's check our yeah so  this is done next you want to go to our data   folder we have this contest and it has referred  the model that we created so you're going to   create a database table name as user now with  this you can try this over here so when you go to   views and let's click on SQL Server  objects so we are going to see a database   now this database let's see the name specified  in this you can see this is the name over here   83 file contest that you know the database so  when you open this last time if it is found here let's try this too okay so that is this you  can see this at the top base now when you   open this database we're gonna have a table  known as a user table so let's see so this   is like you have a user table now let's run  this again and unless you're gonna tell us okay so now let's go for try this out now let's  see it has to return now go to PC that's empty   so let's post a user here this is a user  let's put this so successfully let's get user   now you have one so instead of using this there's  also another way to do it and let's see so we   have to go for view then other windows then say  you're gonna have endpoint Explorer click on this   next we have six right here another name of the  end point so because we have the get host other   kind of person they also here so this is how  you call the a6p file okay so now if I click   on generate request unless you're gonna happen  now you can see I can now generate it with this   request now it has stored the rather the URI over  here with my port so if I click on this let's see   you see I have that list over here so this is the  list that I have I can also grab the same thing   undergrad Simpson but before that let's  go for the Post then which repressed so   there's a request now here you need to pass  in the user data so let's grab this from here and now we need to pass let's paste it  here let's change we don't need the ID   you need well let's say this is screen one  string one click on plan this and now it is done   let's get the whole data we have to  so that is the post you can also get   the ID because you have ID one and two so  generate this past the ID here that's id2   run this and obviously we have the ID too you  can have one you get this only one yeah now   let's go for all that uh that is a put then with  request as you can see from here you can grab this or we can grab this here then let's see you can  also paste this and I'll make an update so the   user that you're updating here it is user ID of  one you want to change this to update change this   to updates okay now let's run this let's execute  this and see now let's get the whole data again   so I get a list of data so this has  let's try this again you see we have   an app updates so that's also done  and we can go for delete pass the ID   up to run this now it is deleted this is the  response here 204 now let's get this again with   the one is off okay so you see we can perform all  that kind of person so we need not to be using the   Swagger UI we can use the HTTP file in it Okay  so [Music] you can see when you come to this   this link you can read a lot about this 83 files  and how to integrate it into your application and   now that is what I have I've shown you but you can  read more right here you can see we can create a   variable here as we did you can create the fourth  Artic variable so you can just grab in the port   there's a URI and other ports so instead of  specifying the portal right here you can just   create as a variable here so the next time  you can change the variable maybe the next   one that you want to make a call with it also  it supports all the following verbs so from   um get option get up to connect you can get  everything you can try that right here and as you   can see we have a lot in here that is what we're  going through at the basics one you can just read   this if you want to grab the detailed One battery  you've done the cloud operation how to get a card   operations or how to test your API with that kind  of persons using the HTTP effect okay so that is   it for this video um this is going to be a short  one and I wanted to make it short as well so I'll   try to use the application and it's very helpful  and so I'm going to other times coming here to   test API in there sorry you are in the browser  use 83 file in the same visual studio what you   do what's your code you can test it right here and  it works perfectly fine so that is it thank you so   much for watching if you like what I'm doing give  me thumbs up and see you guys in the next video
Info
Channel: Netcode-Hub
Views: 232
Rating: undefined out of 5
Keywords: asp.net core, Registration, send email using mailkit, mime, controller, service, email service, web api, send email through web pi, smtp, SMTP, pagination, entityframeworkcore, EFCore 7, skip(), take(), skip() and Take(), skip and take, local storage, blazored localstorage, window.localstorage, scalffold, scaffolding, db-first, migration, database migration, scaffolind db first migration, creating models, fileupload, blazor fileuploads, crud operation using SqlServer, CRUD Operation
Id: aET1wbNlShI
Channel Id: undefined
Length: 12min 59sec (779 seconds)
Published: Mon Jul 24 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.