Learn Rest Api's with .Net Core 5.0 | Asfend Yar | Skillshare

Learn Rest Api's with .Net Core 5.0

Asfend Yar, Microsoft MVP

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
80 Lessons (4h 36m)
    • 1. Welcome

      1:02
    • 2. Course Structure

      1:42
    • 3. What is Api

      2:02
    • 4. Create a Web Api Project

      2:37
    • 5. Project Architecture

      2:45
    • 6. Program and Startup File

      4:33
    • 7. Http Verbs

      1:19
    • 8. Creating Models

      2:12
    • 9. Create Controllers

      1:13
    • 10. Http Get Request

      3:05
    • 11. Http Post Request

      6:12
    • 12. Http Put Request

      3:26
    • 13. Http Delete Request

      2:56
    • 14. Code First Approach

      0:46
    • 15. Configure Nuget Packages

      2:08
    • 16. Database Connection String

      3:02
    • 17. Database Ensure Created

      3:38
    • 18. DbContext Class

      7:09
    • 19. Handling Get Request

      2:05
    • 20. Handling Post Request

      2:32
    • 21. Handling Put Request

      3:18
    • 22. Handling Delete Request

      3:02
    • 23. Http Status Codes Overview

      0:48
    • 24. Status Code in Get Request

      3:36
    • 25. Status Code in Post Request

      1:16
    • 26. Status Code in Put Request

      3:44
    • 27. Status Code in Delete Request

      2:49
    • 28. Content Negotiation Overview

      2:28
    • 29. Implement Content Negotiation

      3:25
    • 30. Code First Migration Overview

      2:18
    • 31. Drop the database

      1:13
    • 32. Implement Migrations

      4:44
    • 33. Adding Data

      3:10
    • 34. Configure Middleware For Root Folder

      1:47
    • 35. Uploading Files

      10:55
    • 36. Save File Path inside DB

      5:30
    • 37. Update Movie Method

      2:40
    • 38. Validation Overview

      1:15
    • 39. Implement Model Validations

      3:44
    • 40. Routing Overview

      2:31
    • 41. Implement Routing

      3:16
    • 42. Project Overview

      1:38
    • 43. Relation Between Tables and Entities

      2:15
    • 44. Adding Models

      4:52
    • 45. DbSet and Migrations

      3:42
    • 46. Security Overview

      1:48
    • 47. Register Method

      7:36
    • 48. Hashing Password

      4:36
    • 49. JWT Overview

      3:25
    • 50. Implement JWT Support in Net Core

      6:36
    • 51. Login Method

      8:25
    • 52. Protecting Routes

      3:04
    • 53. Use Access Token

      2:01
    • 54. Role Based Authorization

      8:04
    • 55. Movies Controller Overview

      1:18
    • 56. Adding Movie

      5:09
    • 57. Update Movie

      3:58
    • 58. Delete Movie

      2:48
    • 59. Get Movies

      6:15
    • 60. Movie Detail

      3:48
    • 61. Sorting Overview

      1:08
    • 62. Implement Sorting

      4:52
    • 63. Paging Overview

      1:40
    • 64. Implement Paging

      7:32
    • 65. Searching Overview

      0:43
    • 66. Implement Searching

      4:35
    • 67. Reservations Controller Overview

      1:11
    • 68. Post Reservation

      6:34
    • 69. Get Reservations

      8:28
    • 70. Get Reservation Detail

      3:58
    • 71. Delete Reservation

      2:27
    • 72. Create Azure Web App

      3:35
    • 73. Create Azure SQL DB

      2:49
    • 74. Publish Web Api To Azure

      7:22
    • 75. Azure Query Editor Preview

      1:08
    • 76. Insert Data Inside Azure Sql Db

      1:40
    • 77. Create Api Documentation

      4:58
    • 78. Publish Api Documentation

      2:19
    • 79. Share Api Documentation with the Client

      1:23
    • 80. Embed Run In Postman In Web Api

      2:25

About This Class

Welcome to the Complete Real World Restful API's course with Asp.NET Core 5.0.

This course is made with .Net Core 5.0 which is the latest but you can also use the previous version of .NET Core 3.1 if you want.

The main focus of this course is on the Restful Web Api via Asp.NET Core and C#. So if you're familiar with C# , Asp.Net and Entity Framework Or if you want to create the Restful web api's in Asp.Net then this is the right course for you.

If you don't have any idea about Rest Api then don't worry because in this course we'll cover all the Rest Api concepts.

By getting this course, you can be rest assured that the course is carefully thought out and edited. And I'm always happy to make the helpful content for the students.

So by the end of the course, you'll completely understand:

  • How to create a Rest Api via Entity Framework Code First Approach with all the advanced functions.

  • Implement Status Codes

  • How to add the Routing and Custom Methods

  • Adding Migrations in Web Api's

  • Adding Content Negotiation

  • Implement Validation in Web Api's

  • File Uploading in REST API"S

  • Implement Authentication and Authorization and secure your Api with JWT

  • Implement Role Based Authorization For User and Admin

  • Create SQL Database on Microsoft Azure

  • Deploy Web Api on Microsoft Azure

  • Create API Documentation

  • Create A Real World Cinema Api From Scratch to End (No Copy paste code I'll explain you each and every single line of code so that you can create a complete Real World Apis in Asp.Net Core happily)

This is not a short course this is a complete guide to make real world Restful Api's from start to end. So if you're a busy kind of developer and wanna learn things quickly from scratch then take this course.

Remember...

After this course you'll get all the  Source Code and along with this I'll also share  the links and helping material for the Rest Api's with you but you need your personal Azure Portal where you can launch your web api.

Transcripts

1. Welcome: Hi. Welcome to this course. Learn stressful AP I spit dot in court where you will learn to design and develop real world rest api ice. My name is s fun and I'll be leading you through this course. I'm a software engineer and Microsoft most valuable professional. I designed this course so that anyone can seeking to develop and last the real world rest FBI's from start to finish. The ideal student for this course is the existing system deliver. But those who have some knowledge off sp dotnet and wants to learn SP don't court the FBI's . By the end of this course, you will be able to develop the rest full epi, ice off your choice in discourse. I will be taking you to the world off rest AP eyes and we will cover all the concerts off rest ap eyes with dot net core. Feel free to take a look at the course description and I will look forward to seeing you inside this course 2. Course Structure: in discourse. You learn how to build an AP. I've It s p dot in court. So let me show you what is coming up over the next few sections in the next section will start out with the visits, like an introduction to the very BP I including how such a project is structured. Then we'll implement all the functionality you would expect from an A P. I like getting creating, updating and deleting the resources right after that well connected FBI with sequel server data vis while actually favor court. Then we'll defend territory resources. It's a TV status courts and Colton negotiation inside the B P I. At this point, you will be very much familiar with sp dot in court that BP I. Then we'll jump towards intermediate concepts and digital learned database migrations of Lord files inside the rest, FBI's mortal variations routing and custom at its right. After that, we will move towards the advanced concepts and there's you learn how to add relation between entities securing stressful AP ice where Jada beauty and rural based authorization then loose, get the real world FBI's for the cinema activation. We'll also covered the sorting Beijing searching EPA documentation and EPA deployment. At this point, you will be very much familiar with the sp dot Uncork the FBI and you are in a position to make wrestle AP eyes off your choice. With all the advanced functionality, that time is very short and there are a lot of things to cover, so I will get you in the next section. 3. What is Api: in this video, we'll talk about what is a P I well e p stands for application programming. Interface with Suffers can interact with each other. I guess you don't get it. This definition is 100% correct, according to the software developers who are already familiar with the term e P I. Because they know how to build and use FBI. But the problem is with those people who are not familiar with the term FBI. So in this course, our focus is to target those people so that they can easily pick every single concept behind AP Ice. Let's start with an example. Let's say a person wants to book a flight ticket for Emirates Airline. He first opened the immediate airline website, and here he phoned that the airline ticket waas little expensive so he didn't cease to some other website like booking dot com or Expedia dot com. Let's see the booking dot com website offers discount, so the person just use this website and then says foursome, cheapest Atlantic. It he got number off such visits this impala. Choose this one when he choose this triggered, then he will get all the information off this flight like, What's the time off the flight? Well, how's it possible that this website shows the exact information off all the airlines and their flights? And that's what EPA comes in? Well, this left side is connected with all the airlines databases. Why FBI? Okay. To speak plainly, an FBI is the messenger that takes request from you and test the system what you want to do and then returns the response back to you and in discourse, waking to learn the rest ful. FBI's with sp dot encore So let's begin. 4. Create a Web Api Project: in this lesson leading to look at how to get an Espy doctor core PP a project inside the studio. So the first thing that I am going to do is just fired the studio. No, I will go to this doctrine core project template and click next. Then we have to provide a name to our project. I'm gonna name it Cinema, FBI. You can name it whatever you like, then just create this project. And we received this style of window there. We have some templates for Dr Court application. In this course, we're going to work with the rest ful ap eyes. So we'll choose this ap I template. Then on the top, you can see that this project is going to target Darknet core and I would use the sp dot encore version 5.0, in this course at the time off recording this course, the latest stable version off dot in court is super in one. And this starting 5.0 version is currently in Alfa State and so Microsoft will push it into the stable release. If you're sinks of other versions like Dalton Court, cheaper one then nor worry it's because us using the latest stable version. I'm also using the latest version, but currently it's not stable. And soon, when the markets of dull per team test all the physicists off shortened version 5.0, then they will release the stable version off dot and five point. Oh, Till then, I will recommend you to stay with the dot Inc sleep on one. I know you are thinking that I'm using garden version 5.0, and most of you are using dot encore version 2.1. So is there any core differences? Does It is absolutely not. And a single line of code that I will write with the dot in version 5.0, will be seen on the doctrine core version 2.1. There is no courting difference. All right, enough talk about the dot inversion. Now this create despotic and with studio is going to do some work and milk it off. That a p A project for us. All right, here we go. Our project has bean created. Now, In the next lesson, we will explore the project architecture 5. Project Architecture: in the last lesson. We have feuded over darkness, Corvette PP a project. And now in this lesson, we going to understand the project ark addiction. So here inside the Villa studio, you'll see a solution window. And inside this we have our project. Inside the project, we have this connected services option. It just shows this tutorial and helps the cream just close this and then we have dependencies in this dependence is all the references off The deal foils, luxuries, extricates and newer packages will be placed whenever we will install some third party library. Our deal file. Then Real Studio will put the install, library or deal file in this dependency section. Next, we have properties, and if we expend the properties, we'll get this long setting store descent file. The settings in this files are basically used when we will run this Dalton Core Web AP a project either from the real studio or from the dot net core command line interface in future. Then we will publish our Web FBI to the Internet. Then this foil will not be a part of your project. This file is always useful when we don't have a rep g p a project inside the studio. Now, if you want to store some secrets like connection string, etcetera, then store those things in the offsetting start descend file. All right, so in this AB setting start, Justin file will place our connection string and secrets in the distant former. Now, inside this controllers folder, we have a better for cost controller. We want the start of a work from scratch, so we don't need this weather for cost controller. So what I'm gonna do is I'll simply delete this file. Then you'll see this weather for cost. Plus, just to move this as well. All right, remember, don't delete these two files the problem CS file and the start of dot CS file because these files play a very important role in our project. So let's explored these files in the next lesson. 6. Program and Startup File: let's explore the program and started door ceasefire. I'm gonna open this program dot CS file. That's the entry point off the application. If you have ever worked with the sea Shop Console application and Gela applications, did you know that there's of one men matter and this man matter is used to run the application? Well, same is the case with SP. Darknet gored The applications this man mattered contains a build Web host better and that's physically used to create the host builder, build it and then run it. And whenever a call goes to the main matted it was, use this started class. Now we need to figure out what basically that started class is and how to deal with the started plus for this purpose. This fire, the started class and inside the glass you'll see that we have two batters, one is configured services and the other is configure Matt It It's only saying that this mattered gets called by the runtime and we basically used this matter to add the services to the container. Basically, this method issues to add the dependency injection if you are intermediate and expert, developer and want to implement a dependency injection pattern inside the FBI, Then Microsoft has made it easy for you because now, with the SPDR gold application, you can implement dependency injection quite easily. But at the moment, dependency injection is not a topic. This matter is also used to handle the services in our application. Like MVC services, A temptation services are entity framework services. Later, in this course, we will choose the entity famous services in this matter to work with the database. And as you are thinking there, what's the purpose off this second matter, that is configure minted, and this mattered. We basically used the services to configure that http request pipeline in this mattered will define our middle years. Let me tell you, what is middle were well, middleware is a piece of software that can handle the institute. Be request our response. Let's see, an instant API request comes and History Observer Now on the other end, let's say we have our controller with basically takes a request and send the response. Now we can imagine that between the Web server and the controller, we have a pipeline. So we say http request will pass from this pipeline through Web server to controller. And when the controller send response, then the response will pass from the pipeline from controller to the Web server. Now, wouldn't it be cool if there is some software lying somewhere on the way in this pipeline? And when the request goes to despite line, it will pass through this middle veer. And there we could perform several things. Let's say we haven't attempted Gatien and Authorization Middle were. Now let's imagine that the request comes and History Observer and then the request goes to this pipeline. They're distillate, our A temptation and authorization middleware. So here the authentication and authorization will be done. If attentive Asian or authorization will feel, then the request would be terminated. Otherwise, if the request is valid, then it will go to the controller. And they're this controller village in that the response and since to the Web server with help off this pipeline. So this is basically the pipeline and the middle there. Now, as we move forward in this course, then I will show you how to add the middleware components. All right, just a brief overview off this project architecture, and don't worry about anything like the court in the start of file or record in the program file because this is a built in court that comes along with the dot in core project. And you don't need to panic about this court. If you have not picked their concepts, then don't worry. Because as we move forward, then everything will be clear to you. All right, that's all from this module. Now, I will see you in the next lesson. 7. Http Verbs: Let's understand the different dives off Institute the words Remember that in the world off rest AP ice. We don't use the term crude that is create, read, update and delete. Rather, we used a falling institute. Divers, that is, Get post put and delete. Let's compare the database. Cried Operation with Scdp works well in rest FBI We have posed, rather than create, read discipline East by get put. Is it off update? And, of course, delete remains the same. Well, the working is still same. Get is used to read and get all the data from the external source or database post issues to add some kind of data inside the date of his. But it's usedto updated later. And Bill, it is usedto delete the data before we move forward with this, the FBI's I will recommend you to install this postman in your machine. It's open source offer and moves used this postman so fair to call the scdp words. You can also find the link off this offer along with this video. All right, see you in the next model 8. Creating Models: in this lesson, we will learn how to add the models in the BP project. Let me tell you that models are see shop classes that holds the properties. I'm gonna add a mortar class in the Web, AP project. But adding the mortar class in this project directly is not a good approach. The good approach off ending the mortal classes is at a mortal folder and then at the motor classes in that folder. And doing this will make your court better, more maintainable and understandable. So first, I'm gonna add a folder in this project and name it mortals. Right after that, I'm gonna add a class in this mortals Fuller. And in order to add a new class under attack this mortals folder, add new file, Then I'm going to pick this empty Caesar class. Name it movie. And just at this glass No, In this class, I'm gonna add some properties like I d name and language. So I'm gonna add the first property. That is I d. Well, we'll studio allows us to get the property with help off building snippet that is brought and choice in turkey. And this will make her life easier. This soccer snipper will create a seashell proxy for us. Just in this property to I d just like that. I'm gonna get another property off type string and then name this property to name similarly kid, other property, off type string. And this time we're gonna name it. Language. All right, this is just our mortal class. And now, in order to work with AP eyes, we need to add controller and action methods. So let's try to wear the controller in the next lesson. 9. Create Controllers: in the last lesson, we have added the mortar class, and now in this lesson, we're going to work with that controllers. So what I'm going to do is just right. Click on this control Fuller. Then add a new controller. And right after that we'll get a list off controllers. We'll start with this empty AP a controller. There's other controllers will already contain some built in court and, as you know, that were written from scratch. And it's better to use this empty controller so that we can learn how things actually work . Just select this and then they have this controller toe movies controller and that's anime convention. Your controller name must answer the keyword controller. All right, let's head it. And here we go. Our controller has bean created. Now we'll continue our work in the next lesson. 10. Http Get Request: in this lesson, we're going to implement a STD B words and actions inside this movie's controller. But before this, let's get a list off movies and just initialized this. Don't forget to add the name spaces. All right, then, inside this list, let's have a new object off movie class and let's set some static values for these properties. At the moment, I'm duties used a static data here, but as we will move forward in this course, we'll get the values from the database. But for now, less Keeper were simple, and I'm using some hard coded data here. All right, you know that when we want to retrieve the data in our FBI, then we have two issues that get met it. So all we need to do is just add a get method here and just gentle tintype off this matter to I innumerable because we want to get the list off movies from this method and test reason. I have changed return Type two. I eat invariable and then simply return the movies list. Also, let me add the SDP, get attributes on top off this mattered, and this is to depict get attribute means when we send a get request to this matter from the Web browser are from the Postman. Then a request will execute this matter. Let me turn this application now in the rep, Rosa will get this message that is No. That pitch was phone for this address. And that's because we have deleted this weather for cost controller at the start of discourse and destiny is, um, we getting this error now we're going to invoke that get matted off movies controller. So let's said FBI slash and then add the name off the controller, which in our case, is the movie's controller. Remember that we don't need to pass the word been told her here because the keyboard controller is a convention, and this movies is actually our controller name. Now. When we hit enter, then we'll get the descended are inside our browser. All right, this is a get request. Now let's try to implement the post Request in the next lesson. 11. Http Post Request: in the last listen, we have explored the Guetta Crist, and now we're going to implement The Post Request. So let's go to the studio. And this time I'm going to add another mattered. But this will be a post matter, and that's basically is used to get a movie record or insert the movie record. So what I'm gonna do is I'll add a matted, off type white and Navy boast. Well, this matter is used to add a record, and therefore we need to provide the full object off this movie class as a parameter. All right, I'm going to pass the object off movie glass here. Dysfunction don't need to return anything. So that's why I have said American type off dysfunction, too, right? And now we're going to add this movie inside the movies list Hunger called hell permitted off this movie's list, and that is that. And then fastest movies object here, let me add that scdp post attribute of dog off this matter, which means when we initiate a post request from the Postman, then the call goes to this post mattered. Also, please make sure to set this list too static so that we can share a single copy off this list throughout this controller. Another question is how to pass the date out of this movie object. Well, that's a good point, because in the previous attempt, when we have sent a get request to this matter who are FBI slash movies. Then we got these movies from this list in the chest informer. But this time is it getting the movies from this list? We have to provide the movie data, but not a question is from there. We're going to add the movie because in the verb Rosa, it's not possible to send the Post request. So let's open the postman and right after that, blessed on this application. Well, I believe that you have installed a postman if not then kindly dollars and insight once we open the postman than we going to copy our rep Gerald and pieces here. Then along with this euro, just add a P I slash movies, which is our controller name. This time we're working with the Post Request, so let's say at the institute, be work to post and just select this body there because we're going to pass the debt, Artur FBI in the GIs informer. So let's select jeison now. The interesting thing is that how is it possible to pass the data from this body section to the post matter that we have written in the controller class? Well, in order to get the data from this body, we have to tell the post matter that kindly get that weeded out from the body. So stop this execution and I'm gonna suspected up in studio. And there let's head from body attribute along with this movie object. Now let's on this application again. And in the Postman I'm gonna write some Justin, did I hear? Well, that's the Centex off, Jason. Or just skip object. In addition, everything goes in the curly brackets. All right, let's have some descended A here and in the Jason, we basically deal with key value pair anything on the left. Inside is the key, and anything on the right inside is the value. We have these properties in our movie class, So let's add I d key and set this value in order to write some other data. We need a comma separator and then destroyed the key that is name and just set the value similarly at language and again set its value now in order to send a request. Let's have a big point with this post mattered and then from the postman. Less issue opposed request, and soon the big point will be triggered and you'll see that anything that we have provided in the body off this Post request will go to this movie object that's going to new our request. And here we go now, in order to check whether this movie has been added to a list that's called a get request. And this time we'll get this movie and remember one thing. This movie has been added to this list temporarily, and as soon as we will stop this application, it will no longer be available. Let me show you what I'm trying to say. So if I stop this execution and again around this and send a get request and this time you'll see that we don't get 1/3 movie, and that's because the newly created movie is only available as far as we remained active in this application. Once we start this application, the newly created movie will no longer be a level because we don't have any date of it, but nobody Booth use that service as we move forward in this course. But right now we'll need to understand the basics off AP Ice so that we can pick the advanced conserves easily. So far, we have implemented two methods. The one is get and the second is post, and now it's time to explore the port request. So let's dismiss the put request in the next lesson. 12. Http Put Request: As I told you earlier, put issues to update the record Celeski it up matter just like we have kitchen this post matter, But this time we name it. Put this put matter is just like a post mattered. But we have to provide one additional perimeter and that is I d. And that's because any time you want to update your records from the database, you have to provide the i d so that you can only update the record against some specific I . D. And same is a result with this put request. So in order to put our update the data, we look at the specific index off this movie's list and just past the i. D. And assigned this movie object to that particular index off this list. Also, let me add STD p put attribute on top of this matter. And this attribute specifies that when we call the put request from the Postman then the call goes to this. Put mattered Inside this STD be put at the boat, we will pass one additional team and that is this I d. What that means is we'll send the i d to dis mattered along with the jewel. And that's why I have written this idea here for better understanding. Let's on this application and here we go. Now let's say I'm going to update this movie record. So let's Assam descended on the Postman, then in The Postman. I'm gonna change the STB work to put. And then, along with this a piece last movie. We have to provide the I D, then distrusted over the studio, and we're going to add a big point along with this. Put mattered, then try to send this put requests as soon as we send the port. Request this big point with the ticket and you will see the data that we have provided from the Postman. Let's continue our request, and here we go. Now, at this movie index, you'll get a new record for the sake of clarity. Let's call the Getty quest, and this time you'll see that at this index or movie has been changed. But as he always said, it's only every level as soon as remain active in this application. Once you stop this application, it will no longer be a level and will not work. Now let's try to add the delete request in the next lesson 13. Http Delete Request: In this lesson we get implemented STD p Delete request inside or FBI. And for this purpose, let's go back to the studio and a new method. Then name this matter to delete because this mattered will not return anything. So under a separate and type of this matter toe void and this delete mattered will all the except one parameter. And that is the I D. And when we provide the idea along with this request, then it's simply delete that particular movie against that idea. So in order to remove the movie, let's call the helper mattered and that is, remove it, and this method will accept this I d. And we'll delete the movie against this idea. Right after that, we're gonna add the SED be delete attribute on top of this matter. It means when we call the delete request from the Postman, then the call goes to this. Delete mattered. Also, we need to put this idea inside this STD B delete attribute. It means that we will pass the idea to this matter. Why are out as usual? All right, let's run this application again. Let's say we're going to delay the record against this idea. So in The Postman, let's use this, Ural. And along with that, this add this i D as we come to issue a delete request. So we need to chase the scdp work to delete, and right after that, let's issue that police requests and the movie has been deleted for the sake of clarity, the scholar getting dressed and here you'll see that it's enough to movies we only have one movie left on. The other movie has been deleted. But as he already told you, the scope of this tradition is only as remain active in this application. And if we stop this application and again on this, then you will see that this movie again appears. Don't worry, we'll move forward and we will handle this. Where did all this? But for now, we have completed this module, and now we have a very good idea off. Scdp works. So in the next lesson, we're going to explore the entity favor and we'll set up the batteries so I will get you in the next section 14. Code First Approach: So far, we have developed our FBI in aesthetic. Now we do work with the database and we look at the data from the database with the Help off court First approach. Obviously, you're thinking that what is court first approach? Well in the court first approach, we basically don't design our database and tables was simply, could our mortal classes and ask introduce favored to make the date of this and the desire table for us so imprecise We don't get a database and tables with some GeoEye are graphical user interface when we work with the court first approach than its responsibility off entity favor to make the database and the tables for us. So let's implement the court first approach in the next lesson. 15. Configure Nuget Packages: in this module. I'm going to show you how to installed entity framework and a skilled server nuclear packages inside the PP a project in the previous section. We have worked with that controller, but we have got the data in a static way. Now we're going to work with the database, and this time we'll get the data from the dead abuse. And that's why we need these two packages so that we can make our FBI real time. So let's get started. First of all, let's go to the manage nuclear packages and then just such for respect is that is, I guess off Daughter Estephe core and just installed this package. Now, once this Beckett has been installed, then we'll add another package that is used to connect the SQL database with the FBI and for this purpose will install this package that is Microsoft dot and steve Evercore dot SQL server. Once that this solution is, then then just close this nuclear window. No. Once again, I want to tell you that we need these two nuclear packages for entity favorite and for SQL server database. All right, hope you have installed these packages. Now this unless these packages in the next lesson 16. Database Connection String: in this lesson, We're going to work me that it of this connection string. So let's look at Cinema Devi context class. Well, Entity Framework will look at the connection string with that name which is cinema Debbie Context It means to work with the rigorous We must need to get a connection scene in order to get up in existing I'm going to the start of dot CS file And as he already told you, whenever we want to add some services in our project, we need to define it s felt and you never kiss. We're working with the entity feel it. So just go to this configure services mattered and let's at our Devi context there will register are given context as a service We just need to pass our cinema db context class which comes from this name space. Then here we need to define our connections thing for the service. But now the question is, what kind of red of is we're going to work with in this course, we're going to work with the secret server databases. So in order to access the secret, Sarah was used the Lambda expression and then we'll write use sequel server and we need to resolve the new space for this Right after that, in the parentheses will pass our connection street. Well, there are many ways to pass the connection sitting here, but at the moment, let's go ahead with the symbol one. As we move forward in this course, I will show you how to pass the connections thing where? Some other way. But right now, let's keep it simple. And there were going to pass the connection string. Well, this is a Centex off connection string. All right, now here we need to change a few things. First of all, let's open the secret server object Explorer inside the real studio. There, you'll see the server. We need to copy the server name and then base it here right after that. In the initial catalogue, we need to pass the name off. Where did Abi's? Let's name it Cinema Devi. You can name it according to your choice. All right, now this continuing other work in the next lesson 17. Database Ensure Created: in the last lesson. We have set up the connections thing and now, in order to set of the deliveries, we need to perform a few other steps. Let's go to this configure mattered and in the configure mattered. Let's add the Cinema Devi context object and then from this object we call this date of his property and just ensure whether it's created or not. This insure created will check if the service exists or not. If it exists, then no action will be taken. And if narrative is exist, then this insure it admitted milk it Adela vis and the entire scheme off the red ofhis s. Well, also, this matter is only useful if you don't want to update the database in near future. But in our case, as we move forward in this course will add more properties in our movie model class. And that means we need to implement a migrations inside the leader of this. But for now, let's keep it simple. Unless use this ensure created. Don't worry. As we move forward, I will show you how to implement the migrations. All right, now, 11 on this application, inarticulate of this, Let's go back to the Secret Service Object Explorer and just refresh it. Now if we expend this, then we'll get our did obvious here. If you will not see your database after earning your doctor Kovac FBI, then just make sure to refresh your secret server and you'll see that it is here. All right, in This did obvious our movies table is present, which we have created. Why are divisible property that's coming from the Cinema Devi context class. Now let's open this table and there we don't have any data. So let's try to at the data inside this table here. We don't need to add idee because it's our to implement it. Whenever we aired the property with Akiva idea in the season of mortar glass, then Entity Favor is smart enough to make this as our primary key and auto implement it. So basically, this idea is the primary key off this movie stable and its auto implemented, and in the name and language with this possum values. And here we go. Now, if we run this application and send a get request to the FBI slash movies, then we'll get the data from the database well That's pretty awesome. So far, we have created our database and worked with the get mattered. Now in the next lesson will continue forward with another overloaded get mattered, so I will catch you in the next lesson. 18. DbContext Class: in the purest lesson. We've installed the new good packages for secret server and Entity framework. Now we get to make a connection our FBI with a secret server like or trust approach. So inside of in studio, I'm going to delete this controller because the data that comes from this controller is hard coded. And now we want to get the data from the database. So just delete this controller. No, We're going to explore the court first approach well in entity favorite when we will work with the court first approach, then it will automatically create our database as well, lest the tables. Let's understand this with an example. First of all, we just need to add a folder and name this folder to data. Then in this data folder, I'm gonna add a new class and name this class to cinema Devi context. Let's end this close. Then we just need to drive this class from DB context and this Devi context comes from the entity Favorite court, new space, and we have to resolve the name space for this class. This debate contest class is this possible to work with the data is I mean, it's responsible to cue the leader inside the later up did the leader and the little later for this TV context class to be able to do any useful work it needs. An instance. Self DB Context Options class. The TV context options instance, gets the configuration information such as the connections thing to use that it had destroyed it to use etcetera, the Aegis made to pass an instance off Devi Context Options Class is back it in the constructor. So just add a constructor by using a sniper that is C. D. O. R and hit depth and then this pass db Context Options class as a perimeter to the Constructor Nordeste act. This class has the genetic parameter, and we want this Devi context options to be applied to our cinema Devi context class. So let's specify this as an argument for the genetic perimeter. Next, we need to provide the name for this perimeter. I'm gonna name it options. Now we want to pass this options to this based Devi contest class. We're going to do that but calling the based last constructor by using the base giver and then dispatches options to the base class constructor than inside the cinema. Debbie Contest class. I'm gonna add fun property. So just had a property. Now the question is what this product is going to return. Well, it's going to read in the Devi set off movie, So resolve the name space for this week loss. Then let's name disrupted toe movies. Well, at the wrong time, entity favor will map this Devi said property with ever database table name, for example. If we need this property here as movies than entity Framework will get a table inside the red service with the same name that is movies. All right, now, that is another thing that we need to do, and that is to add a controller. So what I'm gonna do is I'll simply island you controller inside the controllers, Fuller. And this time I'm gonna pick this, have a b a controller with some built in action matters, and then this controller toe movies controller. All right, let's add this and this controller comes with some building matters and we have already explored these STV matters. Now in this controller will modify all these methods so that we can create, read, update and delete it later we have already vert me that controller. But this time we're going to work with the data, please. Right now we have get post put and the lead matter. It's only there in this conductor and now it's a responsibility to work with these methods and provide the database operations. So this stock anyway, let me tell you an important thing that this cinema Devi context is responsible for the red ofhis Kurt corporations and this class will interact with the later this behind the scenes . So just get a feel off type cinema Devi context in the movies Controller and limit underscore DB context. Now we need to resolve the name space and right after that, let's addict the sector and passed a Cinema Devi context object as a parameter. And then we need to assign this Devi context to this field with this field. No, we can access everything that's present in the Cinema Devi Context class. Currently, this get matter is returning the I innumerable off string, but we actually wanted it in the eye innumerable off movie. So let's pass the movie class here and now with this DB context, we can call the movies property that's present in the cinema db context class. And this written all the list of movies from the diaries. Not an important thing is that we have to set the connection string off the database so that our FBI can communicate with that sequel deliveries. So in the next lesson, let's try to add the date of this connection string. 19. Handling Get Request: in this lesson, we're going to explore the other overloaded get mattered in our project. We have to get methods. The one is used to return. All the movies from the leader is and the other is not implemented yet, which basically is used to return on Lee, a single movie against some specific I d. So let's start over. The first thing that I'm going to do is dis make Britain type off this matter to movie because this matter Douillet in the movie object in our previous get mattered. We have got all the movies from this Devi context object, but right now we're only interested to get the single movie. So let's add this Devi context and then just call this movie's property that's coming from this cinema DB context class and finally used a building helper matter that is find And inside this method, this fastest I D. This fine mattered village, and only the movie that matches with this I d. Now just don't result in a movie variable and lessons in this movie, all right? No, it's done during this activation. And if we said the route off this controller toe a p a slash movies. Then we'll get all the movies from the uterus. But let's assume that instant off getting all the movies would just need some particular movie. So if you provide the idea along with this, wrote your Elle and it enter, then this time would get some particular movie against this idea. Knowledge explored, the post put and the little quest in the next lesson. 20. Handling Post Request: in this lesson begging to explore this post matter. So let's doctor lower inside this post matter, I'm gonna pass the movie object. All right, then I'm going to use this TV context and call the movies Property. With that, we get to call the helper. Mattered That is at no, inside this helper. Met it. We're going to pass this movie object. Now, Once we had a movie to the data obvious, We need to tell the date of its to save our changes. So for this purpose, I'm gonna call the save. Changes mattered. And this will save the changes inside the arteries. Now, around this application. And as you know that in order to call the Post request, we need a postman. So I'm going to switch to the postman and there destroyed some descended a here for name and language. The idea is arto implemented because this time we're dealing with the empty framework and the energy favor will automatically improvement the idea in the database, and we don't need to provide the idea here. All right, just send the post request, and here we go. If we should get request, then you will see that our movie has, Bean added. All right, let's stop this application and jump back the movie stable. And if we refresh the table, then we'll get a new record that we have added by a postman. All right, that's all from the Bush method. Now, in the next lesson, we're going to implement the put request, so I will see you in the next lesson. 21. Handling Put Request: in this module. I'm gonna show you hard to handle a put request inside all of the FBI. So without wasting any time, let's just do that with the studio and go to the put matter which you can see that in order to put our updated data, we need to add the i d. And along with this I d. We need to pass the movie object. So let's pass the movie object here as a perimeter and rename it movie object. Now, inside this method first, we just need to call the DB context. And along with debt, we're gonna use the movies property that we have defined in the cinema Davey Context class . Then after this disk, all the building helper mattered, which is find no inside this method, I'm gonna pass this I d and this fine mattered will find a record against this idea that will pass. Well, this whole line means that it will fetch the movie from the Davis against the I. D. That will pass in this method. All right, Now, the store the result in some variable so that we could use this further. I'm gonna name this variable to movie Now, with this movie, we can access all the properties off this movie glass. Now I'm going to update the record. So what I'm gonna do is I'll simply call this name property with this movie. And then let's use this object and golden in property. This line will replace the previous neighbor activity, this new one. All right. Similarly, let's do that kind of thing on the language property. Here we go now in our to save other changes. Just call a save genius mattered along with this db context. All right, now let's on this application. We're going to modify the record against this idea. So inside the Postman, first of all issues that scdp work to put, then we just need to add some Justin data. So let's brought some Justin in the request body offer Any some descended up this past idea along with this FBI Juel. And finally we're going to issue the request, and here we go. Now, for the sake of clarity, let's check the record by simply sending a get request. And here's you can see that our record I get this island has been updated. All right, that's all from this port request. Not in the next lesson. We get to explode the dilated quest, so I will get you in the next lesson. 22. Handling Delete Request: in this lesson, I'm gonna explore the deleted quest. So let's look back to the studio. Let's try to understand the delayed request. Well, this politic West is just like this. Get request inside the delete request. First of all, let's use this DB context. Then we use this movie's property, which comes from this cinema DB context class. And then the scholar matter that is find in this fine mattered. We could have passed the i D and dismissed it well, basically, get the movies against this I d and move story in some variable Naret movie. Then I'm gonna remove the movie against this i d. By using this helper matter that is removed Now, in order to call this ever mattered. Let's use this TV context and along with that, let's use the movies property. Then we're gonna call the re movement it and simply passed a movie here. This line really moved a movie. Then we need to see the changes in the service by using save changes mattered. So we have added the functionality in this diligent rest. And now, in order, check this. We first need to run this application and I'm gonna send a get request. Let's say I want to remove the movie against this idea. So all we need to do is set the STB work to delete. Now remove the movie against this idea. So let's pass this idea along with the U. N. L. Then just issue a politic West. And here we go. Now, just check, rather than movie has been delicious or not. So under initiate that get request. And this time you'll see that this movie is no longer available. All right, so we have successfully implemented that Get post put in the league matters inside of our baby I Well, this data comes from the secret of it that exists locally on my machine and later in this course will deploy this FBI and database to the online hosting server so that it can be live over the Internet and can be accessible on every device. All right, that's all from this lesson. Now, I'll see you in the next section 23. Http Status Codes Overview: http Status golds are standard response codes given by website servers on the Internet. The courts help identify the cause off The problem, then of a pitch are other. Source doesn't lower properly. Scdp status course are sometimes called browser records Are Internet intercourse. I'm sure you have seen that kind of a record. So whatever you request a source on the server and if it's not phone, then you will receive an editor. And basically it is a huge list off is too deeply. Status Court and I have attached the document with this video so that you can read the star discord and their functionality. Let's try to add the status code in our Web FBI. 24. Status Code in Get Request: in this lesson. We're going to add the status code inside of the FBI and we'll start with the get request. So let's misted over the studio and there start to add the status scored inside our project . Well, I'm gonna start with the get mattered. We'll need to add the Status Co 200 which is okay whenever we want to add the status court . Then we have to face some kind of error. And that is we cannot return the status code within this matter because this matter is off type I innumerable and in auditor than the status scored. We will need to set a type of function toe i x and result. And here we go. My action results offer some sharp words for the status court. Like if you want to implement that success that the score, which is off course 200 then simply call the okay matter and just awesome movie object. And this documented village on the status scored 200 as the less all the list off movies, if you want to return 400 are bad, Equestria then simply didn't the bad request function. And if you want to written for a four or not phone status code, then simply than the not phone method. And that's the beauty off I action result. But what if you want to it in some other status codes? This chocolate matter doesn't go where all the possible status courts for this purpose. We would use the status scored function, which accepts and into your barometer, and we can pass our status court here in indigent form It, for example, if you want to return to Hunter Status Court, then passed 200 here. If you want to return for one status code, then pass for one here. In fact, you can pass here the status code as per your choice. But it's almost impossible to remember the status scored by just number. And that's why Microsoft has made this easy for us. No, we don't need to remember the status scored vine numbers. All we need to do is just use the status court class, which comes from this name space that is Microsoft daughter. It's been a core dot scdp, and with this status course class, we can access the status code off your choice. So here you can see that we have a list off satis course, and the name of status score tells us what the status scored is about or what number it will return. For example, status court created is equal into 21 and satis court bad request is equal to 400 desta logic behind the status court. In the great request, we just need to return that 200 status court and weaken simply return this. OK, Matt it because this okay matter. It means that it will return that 200 status court. All right, you food on this application and send that get to question And if all request is successful , then we'll get 200 satis court here. 25. Status Code in Post Request: the status code to one is for created. What that means is, whenever you will need to add something on the server and if it's created, then the server will respond back to you and send a status code to one, which means you're record has been created. So let's try to add the status court inside the force met it. First of all, I'm gonna change the type off this function toe I action result, then simply send the status coat and passed a status code that we want to expect in our case. It's the status code created to a one. Now, listen, this activation and justice to the postman there, I'm gonna add some descended up and send a Paul Syquest. Now, what's the record is created, Then the server will send the status code to one, which means our record has been created successfully 26. Status Code in Put Request: in this lesson, I'm gonna add the status scored inside a put request. First of all, let's change the return type off this function toe I action result, then lesser than an OK, Matt, it Now on this on this application. And let's try to update the record against this idea. All right, here in the Postman, I'm gonna wear some decent data and then send a put request soon will get 200 status coat, but with a minute. What If you want to extract some message along with the stethoscope? Well, let's do it. Justice to the real studio and inside the okay mattered. That's a message that is record updated successfully and now, once again, run this application. Now, this time, if we send a put request, then we'll get both sides scored as well as the message. Now, what if you want to update the record against the I d. That doesn't exist in the database. Well, if we send a put request against some I d that doesn't exist in the data vis, then we'll get an exception. So first we need to resolve this. If the juicer will try to update the record against some I D. That doesn't exist in the service than instant off this exception we neutered and some Jew differently. Message. All right, let's start this execution. And inside this put mattered. You can see that this line will get the record against this i D. And if there is no record found, then we need to check whether this movie is no or not. If it's no, then just ride the not phone status code and passed a message that is no record phone against this idea. You can also pass your own message here. Now we need an else block that will be executed when the record found soon as aired on else block and put everything inside this else block. Now, once again around this application and this time, listen, the put request against this I d and you will see that our record has bean successfully updated. Now the send the request against the I D. That doesn't exist. And this time you'll get a message here, and that is no record found against this. I d. All right, there's awesome. Now let's try to add the status court in that delete request, So I will see you in the next lesson 27. Status Code in Delete Request: in this lesson, we could add the http status code inside the delete matter. So first of all, let's say a certain type off this matter to I action result and then listed in the or committed and passed a message here that is record deleted. No, that's on this application. And this time I'm going to delete this record. So we need to pass the I D and then send it a little quest and you'll see that our record has been deleted. All right, now, what if we did the record against the idea that doesn't exist? Well, we'll get an exception message, so we just need to do the same thing that we have applied earlier on the port matter. First, we'll check if this movie is no. Then let's add the not phone set A scored with some message. And if the movie's not know, then the four record will be executed. You can wrap discord inside the else block just for the sake of clarity. All right, Once again, we didn't run this application, and this time let's try to delete the record that doesn't exist in that Hillary's And here we go. We'll get a status code here with the message. All right, That's also we can also do the same thing on the second overloaded. Get math it in the second, overloaded get matter distant certain type, too. I exit result, and then let's check if the movie is no, then simply them, but not phone mattered otherwise lets it. Then the documented and passed this movie here. So that's basically the Jewish Off Status Court. You can add the center score to the FBI according to your choice. All right, so that's all from this module now. I will see you in the next section. 28. Content Negotiation Overview: in this module will see the FBI content negotiation. So what is content? Negotiation? One of the standards off restaurant serves is is that the client should be able to decide the former off response from the server. For example, if the Klein wants the response in XML or just informer and so on. Iraq Land Sense A request to the server. That crest includes something gall except Header. Using this except Header, the client can specify the former, which they want from the server. For example, if the exception is exit bill, the server sensor response in XML Former If it is Jason, then the server sends the response in just informer. Let's understand this content negotiation inside the FBI. So let's on this application Right after that, I'm going to open the postman and just based this a p a u l here, then we just need to provide the accepted value. So I'm going to click on this header step, then just said the exceptional value toe application slash Jason and then just initiate this request. We have got the data in dis inform it Now let's look on the head is and see the content negotiation magically on the header. The content type is application slash Jason. That means the client has requested the output in Jason form it well by default in SP dotted Kulaib FBI, The response comes in just informer Heiler. If you want to get the response in example former, then you just need to specify the exceptional value toe application slash xml And if we initiate the request, then this time we got a data again in the GIs informer. And that's because by default of SP, don't go. Rep FBI Only sports dis informing And in order to receive the data in excellent former, we need to configure our daughters core PP a project so that it can sport the example former so in the next module will implement this feature. 29. Implement Content Negotiation: in the last lesson. We have seen that our SP gotten core PP. I cannot handle the accelerator and the response always comes in the Justin former. Now, if you want to get the response in the excellent former, then we need to perform wanting inside our project. So just back to the studio and here let's open the start of dot CS file Now inside that configure services bettered. We just need to add the Accival civilized or for matters along with this embassy services. All right, this line village and response according to our choice, Let's not this application again. And in the Postman. If I send requests with exceptional value to XML, then you'll see that response comes in the exhibit. Former. And if I type the accepted her value to application slash Jason, then we'll get the response in the just inform it. So far, so good. If the client wants the XML forward, then he will have to provide the accepted her value to application slash XML and he will get the data in the Accival former depending upon the accept our value in the request. The server since the response this is called s content negotiation. Now remember one thing. If we don't send the except better value than by default response will always be in the just inform it. Let's try this So I'm going to remove the accepted or value and just execute this request. Now we have got their spoons in the Justin former because in SP, Dalton core by default response comes in the DIS inform it. No, we'll understand what, over a p a does when request for specific data. Remember the FBI Denise Controller data that we want to send to the client in our example the movies controller regenerating the movies list, which we want to return to the client. What's the list off the movies is generated. The jump off the controller is done. It's going to hand that list to the A p a pipeline. Whiston looks at the exit header and depending upon the former, which Grant has requested the FBI the Tuesday appropriate for matter for formatting the data. For example, if the client has requested data, in example, former the FBI's uses example for matter, and if the client has requested for descended a the FBI uses suggested for matter, these four matters are nothing but classes, and they're called media type for matters. All right, so that's all from sp dot Encore the baby. I content negotiation now. I will see you in the next section. 30. Code First Migration Overview: in this lesson wicked to explore the court first migrations. But for this I want to tell you that why we need code first migrations In order to understand this, suppose that after some time you have been asked to write one property in your existing movie class for movie rating. So far, we have two properties in the movie class now leading to write another property. So let's add a property off type double and limit reading. This property is basic. This used to tell the movie rating after adding the property list on this application. Now, if we issued a get request, then you will see that it's tough. Getting that data will get this Arab age, which says invalid column name rating, which we have recently added in our mortal glass. The reason we getting this error is we have changed our mortal class properties well, as you know, that in the started class, we have used this date of his thought. Ensure created mattered, and this matter told us that it will only be useful if you want to create your date of this first time, and then you later changed any specific model than this mattered will not help you. Also, this method is only useful when we assured that we will not change our database column or Schemo. But in our case, we have changed our movie mortar class, so this matter will not work further. So how can we solve this problem? Well, if you believe that you will not change your mortar plus in the near future and you can simply use this ensure created matter. And if you're not sure that whether you will change your database scheme or in the future or not, then you will need migrations. So in the next lesson will implement the code first migrations inside our V p I. So I will see you in the next lesson. 31. Drop the database: in the previous lesson. We've added one property in our movie class, and when we sent a get request, then we got a problem. Now we're going to fix that problem with help off migrations. But before this, let's move this database. Start insure created court because we don't need this now before adding a migrations, I want to tell you that we have already added our database and the movies table with help off database start insure kitted mattered. So we first need to delete a gate of this before adding the first migration in the sequel server Object Explorer we have this did abuse and the always stable. So this strike with the leader, do you notice? And here we go. The new service has been deleted, All right? So far we have Did it ever did obvious. Now, in the next lesson, we'll get a database and schema with help off migrations. All right, I will see you in the next lesson. 32. Implement Migrations: in the last lesson, we have deleted the data ways. Now we need to get a little bit again without off migrations. So in order to add the magician, let's go to the package manager console. If you cannot see this brackish, magical, still option here, then just go to the search bar and search for package measure console and just select this . Now in the package Manager consult will end a command for migrations and that is at dash magician and then given him to your migration. I'm gonna give a falling new to the migration that is initial create. You can name it whatever you like, but mostly we give it a name that identifies the kind off a change that we have made in our demand model. All right, just hit. Enter. Now, once we hit enter, then we'll get this message here, which is? This government is not recognized. So it means we don't have necessary package which enable start migrations. So what I'm gonna do is uncle the manage nuclear packages. And there. Let's search for this practice. That is Microsoft dot ntv, AmeriCorps, dark pools. Basically this package it's used to enable the migration commands. Let's install this package. No. Once again, back to the Pakistan's your console and there I'm gonna add the migration. But before this politically this so that you can see that commands in a more visibility. Let's use that clear command. And here we go. No, we're going to add the command, which is at dash Migration, and then given him to your migration. I'm running it initial create. Then unless it enter And here we go, our migrations are added with this name not in the Explorer window. We have a new followed that is migrations and just look under migrations. We have a news T shirt class. Let's open this heavy hell of migration. Well, you can see that we have to matters. The one is up, and the second is don't, as you can see, that the up matted contains score for creating database objects, and the donated contains scored for dropping or deleting the date of his objects. No, this close this, and so far we have added the migration. But we're not done yet because so far we have just had enough migration script that's responsible for creating the database and the tables. But we have no created the actual database and the tables. So what I'm gonna do is I'll go to the package manager console and there under add a command that is updated dash database and then at the name off the migration. In our case, we have just one migration, and that is initial create. So if you have just one migration inside your project, then you don't need to pass the name here. All right, just use this update dash database unless it enter. And here, this is going to apply the changes to our database. All right, now I start to run this application, so let's run it. And this time, if we send a get request to this AP s last movies, then we'll get these to scare records. It means that our A p a. Is working fine. But we don't have any data inside our databases, and that's why we getting these ft scare records. So let's try to add the data in the next lesson. 33. Adding Data: inside the last. Listen, we've added the migrations, but we don't have enough data inside the disservice. And that's why we got these empty scare records. No strike at the later inside the database you can at the data, while multiple ways. The first method is to send the Post request and second East toe at the data directly inside the database. So let's go to the Secret Server Object Explorer and there. Let's refresh it. And here, little get over did always. Let's expand the date of this and let's open the movie stable now inside the moose table. We're going to add some data here, all right. Now, if it's this back and send the get across again, then this time you'll see that we have got a data in the Justin former and this day that comes from the database. Now let's fight to update this record by using STD. Be put, Matt it So inside the postman I'm good at the distant deter. Then let's add idea in the rural and finally, let's send a put request, and here we go that it has been updated, but if we send a get request, then you can see that all the fields are updated successfully except this creating field. Let us respect to the real studio. And there. Let's go to this movie's controller. Now it's a put. Met it. You can see that we have used these properties to update the movie record. But we have Mr Property. That is movie letting. So all we need to do is just use the rating property here and updated accordingly. All right, let's add disrupted here and assigned the value. Now, let me run this application once again, and we're going to update this record. But just sending a put request, all right? Not just sick whether this record has been updated or not. So if we issued a get request, then this time you can see that our record has been successfully updated. All right. So far, we have covered the court. First migrations inside our doctor. Corrupt FBI. No, I will see you in the next section. 34. Configure Middleware For Root Folder: in this lesson begin to work with the file. Uploading with Dalton Chorus Filippi eyes. So before uploading the file, let me tell you the basics. First of all, we need a folder inside our daughter core project that is, www wrote. This debate of your root folder contains all the files that will upload. Remember, definitively. W Root is a convention, and this folder basically comes with SP Gotten core project, and this folder is used to hold all kind of static content, like images. STL files. Jalisco files, etcetera. So, first of all, let's go to the project. And there let's get a new Fuller and provide the accept similar, which is www route. And here we go. This four has bean created, and you can see that the ICANN for this folder is different from the other folders because this folder name www route is a convention, and you have to follow this naming convention. Now let's go to the start of door, see his file and inside that configure matter, we need to destroy our middle there to access this www root folder. And for this purpose, let's use this app door, you static files method Nor, with this line, our vet AP. I can access this w w root for her. All right. Now let's continue our work in the next lesson. 35. Uploading Files: to upload the files in doctrine, core PP I We need to understand a few things. Currently, we have these properties inside of a movie class. Now we people at another property, which basically shoes to handle the images. But the question is, what will be the data type off This property, though, will choose the data type off I phone foil which comes from this near space Microsoft Door sp net core dot STD. All right, then, name this Roberty two image. Okay, Now, this image property will not be a part of our movie class because, as you can see, that the data type off this property is I form file, which is not a valid data type for database table. Our sequel that obvious doesn't support this iPhone foil data type. The second most important thing is that will not store the images inside the rate of this because storing images inside the date of this is a bad practice, and this will also increase the rate of its size and reduce the performance off the rate of this. But now that person is there will store the images and how to retrieve the images inside our baby P I well, Buddhist or the images in Www root folder, and then we'll pick the parts are name off the image and store it inside the database. And next time when we will call the get mattered, then we'll get the image pot. And after congratulating the image part with the Rep Ural, look at the image, All right, so in the movie motor class, we're not going to use this image property inside our movie table. And that's why we have been to add a not mapped attribute on top off this property, which means this property will not be a part of our movie table. All right, then we need to resolve the name space for this, not Mac attribute, which is system component model dot data innovations dot schema No suited the movies controller. And for a moment that's copy this post mattered and place it here, then come in. This previous post mattered. Now, in this post matter it, we're going to start river to upload the files. As you can see that we have used our from body attribute along with this movie object, which means pull send the distant data to dispose mattered via from body. That's we stood up, postman. And earlier when we send the post request, then we use this from body to send the distant data. OK, But this time we get to send up file along with this descended up so ho to pass Both the file and the descended are in a single question. Nobody is simple this time Inside the postman We have this from data which basically takes the key and the value in this form. For example, in the movie motor glass, you can see that we have the full of properties. Let's start with this movie name, property and the key will pass the name and then in the value Despots of value. All right, then, reduce this language property and in the value despots of data. Then we'll just the rating property and passed the value here. All right, now, what about this image? To use this image, we first need to set the type off the ski tow file, and then we'll get this option for picking the file. Okay, Now I'm gonna pick some file. Let's pick this image and here we go. Remember, we don't have completed our boss matters yet So we're not going to send a request Instant with first switched it of in studio and there will complete our boss mattered So inside the post mattered. We removed this from body attribute because this time rules use the descended at yr form data. So we'll use star from form attribute now inside the sport Met it Just move everything because first we will learn how to upload the files. And once we learned the file uploading then I will show you how to save the file part inside the database. Basically, there are a few steps that we need to follow to upload the files inside. The bush met it. This used the part glass with this part class, we can pick this combined method. This method is basically is used to combine the strings into parts we need to combine the www root folder and the file them. So in the first barometer rules, use www root folder in the double courts and then the second Prague. Later, we could pass the name off over fight. We can pick the name off the file with this movie object. Let's use this movie object and then we'll pick this image property that's coming from this movie class. And right after that you can see that we could pick this file and function with, basically to install. Name off the file. But instant off. This approach bulls you some healthy approach because if the user will post the two images off same name, then David be a problem on the server side, chances are that will get exception or the second image will replace the first image. So this is not a good approach. The good approach is to make every day. It's unique now how to make every image Vinik for this purpose. We'll use the C shop G I. D. Our globally unique identifier instruct, and I love the debt. Let's pick this new Geo I d. Every time we call this boast matter than a new you. Nicky will be generated just because off this Jesuli D. Now let's say the user will add an image. ABC. Then our jaidi will relieve that embassy image to some unique name. Next time, when there's user poster image with the same name that is a busy. Then again, this do I D will lean in the second image with some unique name. All right, now on a story This result in a very evil and we name it Geo I d not in the parts dark combine. We have used a little bit of you Root folder and in the second parameter Blue Costis Geo I d. Right after that, I want to tell you that once the usable add the image than on the server side will convert that image in tow. Deputy form it. No matter what kind of image the user has posted it maybe BND or DPD former but on the service side will convert all kind of images to deputy for mint. So along with this Geo I d won't congratulate the door gpt All right, now let's start it in a variable and we name it file. But after this line, who was used to file handling and streaming But before doing the file handling operation will check if the image that will get is no or not. If it's not know, then we'll add the file to a server, otherwise will get an exception. So it was used the F condition and check if movie object our image is not equal to know. Then Bulls used the court here, so let's get a new instance off file stream plus. Well, this file stream class is basically used to handle the files it's used to get open the files. Women pass two parameters here, the file part and the foil moat. Let's pass this file part and in the file mode will juice create because we're going to create the files? Okay, now, to set the file on the server rooms used this movie object not in this property, and then we'll call the copy to matter. And this method says that it's going to copy the content off the uploaded file to the targeted stream. Now in this copy to Mattered will pass this file stream. All right, this is the whole court to upload the files to the server. Don't worry about the database spot because we'll call it shortly. But first, let's run this obligation Now inside the Postman, you can see that earlier we have added the file. Now we're going to issue the request and typical now back to the studio and inside the root folder, you can see that we'll get an image file here. All right, let's do it again. So in the postman, let's do some other image and then send the request. All right, here we go. No, back to the studio. And this time you can see that we have this image inside the root folder. All right? Knowing the next lesson. Let's start the descent. Deter an image part inside a later. This. So I will see you in the next lesson. 36. Save File Path inside DB: in the last lesson. We have uploaded the files to this root folder. No, In this lesson, we're going to store the distant data and the image spot inside the date of this. So what I'm gonna do is I would use the DB context, then pick the movies Poverty that we have reading in the cinema Debbie Context class, and then lose used the admitted and passed this movie object now to save the changes rules use to save changes mattered. All right, And were it and the status Corbett is created. Or 21 this court will and our movie record inside the movie stable. But what about the image file bought? If you go to the movies stable, then we don't have a column for holding image file pot. So what I'm gonna do is I'll go to the movies class and there. Let's sell a property of type string, and we're gonna name it image General, as you know, that we have added a new property inside the movie class, so we'll need to add the migrations. I know you are thinking that we have added that image property and we have not. And in the migration. So why this time when we added that image your property, Why we need migrations? Well, that's because this time the image your property will be part of our movie stable. And this image property has no link with our movie stable. And we have used to not nap attribute on top off this already. Okay, so go to the Pakistani console and they're less other migration by shooting the command that is at the X migration. And they've your migration. Do whatever you want. I'm gonna give a falling narratives in which euro edit All right, let's it enter And other violations were edit. Now this every the database by using the command opted Dash Hillary's and add a magician named here. Now we're going to switch to the movies controller and inside the bourse Mattered will pick this movie object dot image, Ural. And then let's assign this file path to this image ul property. So, in our we add an image than this line will be executed. And we'll get some unique name along with the depleted of you root folder. And then we'll assign that file. Part two were Image your property. Now listen. This abdication. And inside the postman, let's add an image and some just litter. Then send the post request. All right, here we go. Now, let's go to the movies table. And there you could see that we will get the image. You're here. All right. Now, this issue a get request. And here we go. We'll get an image. You right here. Now, when we append this image wherever they were broke up, Ural and send a request, then we'll get the actual image. But remember, we need to remove this www route, otherwise this will not it on the image. All right, here we go. If you don't want to store that www root folder name inside a database, then just go to the post matter. And after this file got, we'll call the remove Mattered this the movement, it will take the ridge. Let's say we want to remove the www route from the file pot. The range start from zero index to six index. If we supply the range from 0 to 7, then this three movement it really move this www route. All right, now let's turn this application again and let's hear some descended er and to some image. Let's issue a post request, and here we go. Now, if we switch to the movie stable, and this time we'll get that image you'll hear without Www route. All right now in the next lesson will continue our work with the put Matt it, so I will see you in the next lesson. 37. Update Movie Method: in this lesson. We're going to update the put mattered off movies Controller class. In the last lesson, we have uploaded the file to the server via Post Request. And now in this lesson, we're going to work with the foot mattered. This put method will be used to update the movie record. So we will, at any slight modification in this matter it Do you remember the Post? Met it? I'm talking about this one. We're going to regions the same code inside the put matter. First of all, let's say the from body attribute to from former attribute. Then let's copy this court and basit ears inside the port mattered Now in the post matted. You can see that we have used this line to assign the file part to the image. Your property? No, This time we have a different scenario. We need to copy this line and pasted inside this if condition it means if the image that will pass is not Mel, then we'll add a new image. And if we don't want to update the image, then this court will not be executed. Levin and this application, so that you can get the better idea off how things actually work under the hood. So here, inside the postman, I'm gonna issue a get request. Now, let's see. We want to update the record against this Heidi. So earlier, we have used a post request. No. This time we could visualize the put request. So let's since the recipe be world to put and then let's see in the distant data and the image against this idea so we'll pass this idea along with the general. All right, now, let's issued a put request. The record has been updated. Now, listen, the get request. And this time you can see that a record against this I d. Has been updated. All right, so that's all from this lesson. Now, I will see you in the next section. 38. Validation Overview: in this lesson, We're going to explode a model validation inside our rep e p I. So if you're new in mortal validation, then this lesson is for you. More of the tradition in S B. Dalton Court, Embassy and SP talking call the FBI are very similar. Once you understand the concept, you can implement it anywhere, but not aggressiveness. Why we need to very did a model. Let's assume that you have been asked to provide the movie name and language. But instead of providing these necessary things, you send the post request without passing the values to these parameters. And as a result, the know are empty. Value will be stored inside that it obvious. And later, when someone will issue a get request, then he will get the empty data. Now the question is, who is responsible for that kind of mistake? Well, it was the task off, back and developer, and he need to take off these very addition rules. So in our case, we are the back and developers, and it's our responsibility to handle the validations. Now, in the next lesson, we're going to implement a mortal traditions inside our FBI. So I will see you in the next lesson. 39. Implement Model Validations: in this lesson, we're going to explore the regulations. But before this, let me show you five. We need very edition. Let me quickly on this application and in the course, man, we're going to post a new movie record. This time, let's say we don't provide the value for movie name. And when I sent the request, then they request becomes successful and the record has Bean edit for two. Sick of clarity, let's issue a get request and here you'll see that the record is added, but the movie name is not present here. That's why we need to add relations so that we can get that correct data. All right, let's go to the movie class, and we all know that moving him cannot be no. So just add required attribute on top name property, and this required attribute comes from this name space, which is system the component model. Don't date our traditions. Well, SP dotted core comes with several built in attributes for relations like when we will add record attribute on top off our mortal class property that it means this property is required and cannot be no are empty. Now listen to us the language. Well, if you want that language feel cannot be no, then just add record attribute or top off language. Similarly, let's add record attributes on the other properties. Now let's on this application and inside the Postman. If we send their quest without passing the values to our descended on, then will get this message, which says that these things are required and without passing the values that data cannot be edit. All right, you'll see that building error message here. If you want to pass your own custom message, then you can change it quite easily. Just go to the movie motorcross and on top of this name, property and in the record, actually, Butte, let's use the other message. Property equals and pass a message here, like name cannot be no are empty. All right, you can pass the message according to your choice. Similarly, we can pass the error message on other properties. Now let's on this application, and this time, if we don't pass the values to these properties and send the request, then we'll get the custom. Aramis is here. All right. Now, if you provide the values and send a request again then this time our record will be added . So as we move forward in this course, then I'll don't you more about the moral traditions. But for no, that's all from this lesson, and I will catch you in the next section. 40. Routing Overview: in this lesson, we'll discuss activity trotting introduced in Dr Corvette FBI with an example. So let's get back to the studio and inside the movies controller. You'll see that we have to our load off, get matters and we have added these matters with STD B Get attribute. Now, for the sake of clarity, let's add another get mattered and the purpose off this matter it is to accept one perimeter off type in desert and simply written that variable. Well, I'm gonna write this matter. Just explained you the concept. And once you understand that after be trotting, then we'll apply the concerts later in this course. So this animated here and we name it best. And this matter is shoes to accept an I. D perimeter and simply return this idea value. No, I never did this application. And inside of a browser, let's issue a get request against this matter. It well, just at the idea along with this Ural and this world and the movies against this idea, in simple words, the call goes to this Get met it. And this test mattered the largely executed. Now, if we add http get attribute on doubles dis mattered. Run the application and against send the request. Then this time little get an editor, and it's saying that we have to matters off. Same signatures are multiple actions phone against the Sechrest because right now we have to get methods that accepts the idea. Burr bitter. And that's the reason we getting this parrot, because when recent a chaotic West, then over FBI cannot officiate between these two methods. We have to fix this issue and we'll solve this wire activity voting. So in the next lesson, let's understand the activity trotting. 41. Implement Routing: in this lesson leading to talk about the activity voting in the last. Listen, when we sent a get request, then we got an editor because dark and corrupt FBI cannot differentiate between these two get methods that accepts the same parameters. Now, let's see how to resolve this. Where Activity roti. So what I'm gonna do is I assisted out real studio. And here on top of this movie's controller, you'll see this road active attack. And inside this we have a P I slash and then the controller in order to access this movie's controller when we passed a p a slash movies from the Liberals are are from the Postman. Then this wrote mast with this controller and then the get post put and village action matters will be invoked depending what kind of request we sent from the postman. Now, I told you that there is an ambiguity between this get mattered and this test mattered. I never bp. I cannot differentiate between these two methods. So what I'm gonna do is as use the activity voting to fix the problem for this purpose. Let's fast action token on top off this desk, Matt. It right after that, we need to pass the road perimeter for this idea. So in order to add this idea here, we need to juice slash and then introduced according records and put our idea here. All right, When we call this get mattered, then ever wrote becomes a p I slash movies, and when we call this get matter, then the road jewel becomes a B I slash movies slash idee. And then when we call this desk, Matt it, then that old jewel becomes FBI slash movies, which is our controller name and then the action matter name, which is best. So that will be that you are to access this test, Matt it. Now let's run this application. And instead of a Broza officials a p I slash movies that it will load all the buoys from the database. And if we specify the idea along with this you earl, then it will order specifically against this idea. And in order to call the test matted, let's use this. So that is FBI slash movies, slash test and then just had an idea here. Now, if we send the request that this time you'll see that our request is successful and we got a response from this request. So far in this lesson, we have covered the activities roti. Now, as we move forward in this course, then bullets used the activity voting in our real world FBI development. All right, that's all from this lesson. Now, I will see you in the next section. 42. Project Overview: Hi. What? Come to another episode off this course in this episode, I'm gonna show you a little story. Well, a client came to me and said that he wants to develop a mobile application for his business so that it can be easy for his customers to book the cinema ticket. So I asked all the requirements from the client. He told me that he need an application just like this, which includes the sign up each, the log in page and whenever the user will log in the application, then he will get the movies which are going to play in the cinema. And if the user wants to explore some particular movie, then he can tap the movie and he will get the necessary detail off that particular movie. Then the next step is that if they just wants to book the movie ticket, then he just need to provide the necessary details, and West the user will provide all these details. Then he can look the movie ticket. Now there will be another application for cinema admin, and this is used to add update our village movies. This app will also be used to check the information like which user has booked a ticket, etcetera. So in this course, we're not going to make this mobile application. However, we're going to build a complete beckon. Services are less full AP eyes for this mobile application, but before this, we need to understand the relation between our tables and entities. So let's try to understand the relation between the tables in the next lesson. 43. Relation Between Tables and Entities: in this lesson, I'm gonna show you how many tables we need. And what's the relationship between these tables? We basically need to tables for our did obvious users, movies and reservations. Now, let me tell you this your table will contain the Jews. A date I like is the i. D name, email, password and Jesus role. This funeral property tells that whether the student isn't admin or a normal user, So we would use this URL property to differentiate between the user and the admin. Okay, then this move stable contains some movie state are like movie I d movie name, description, language, moderation, blinged it, playing time, etcetera. Then we have another table that is rather missions and stable. Contains the folding properties like reservation i d quantity, which tells that how many tickets the user wants to book price property tells that what will be the total price after you the tickets Full property is basically shoes to handle the user phone number, and the reservation time, as the name suggests, is used to handle the movie restoration time. All right, so these are the tables that we need to make a baby. I now let me tell you the relationship between these tables and the entities I start with the users once you second deserve one are more than one movie. So there will be a one to many relationship between the user and the reservation and to do the I d with a foreign key in the reservation table. All right. Now, against one movie, there will be one are Morton one reservations, Which means there will be a one to many relationship between the movies and the reservations. And the movie I d will be the foreign key in that is a recent stable. All right, so these are the relationships between these tables and the entities. Not in the next lesson. Weaken to make the mortar classes from this picture. All right, seal in the next lesson. 44. Adding Models: in this lesson, we're going to add the motor classes for user movie and preservation. So let's go to this project and inside the Models folder, Let's get a new seizure class and name it juicer. Now, in this user class, let's had these properties one No one. Once we had these properties inside the user class, then we'll add a new C shop class, and this time I'm gonna name it Reservation. Now, in this reservation class will add these properties. All right, Now we need another class for movie. But as you can see that the movie class is already insider mortals folder so we don't need to add the movie class again. Brother will try to modify this class. So what we're gonna do is will simply remove these properties from them. We class not remove this image property off iPhone file because rules use it to upload the images. Then just add the following properties inside this class under one. - All right, here we go. Now, as I told you earlier, that there is one to many relationship between the user and the reservation and movie and the reservation. So how do I make a relationship between these tables. Well, there are certain conventions in entity framework which we need to follow inside the model class, and it will automatically get off one to many relationship between two tables inside a little ways. You don't need to configure anything us, miss. Take a look at the conventions, which will create a one to many relationship. We want to establish a one to many relationship between the user and the reservation entities where one user can deserve many movies. So the convention is to include ah collection navigation property in the principal entity. In our case, I will add this collection navigation property inside the user class. Well, there are also many other is to make a one to many relationship. This is just one that I'm gonna use inside this project. All right? So just include our collection allegation property off time I collection off doesn't miss in class. Don't forget the resulting in space. The Nivet reservations. Well, this will result in a one to many relationship between the user and the reservation entities. Similarly, there will be a one to many relationship between the reservation and the movies. It means that this one or more than one reservation against the movie. So let's go to the movie class and dear, this ad, a property off type I collection, off class reservation and then it further divisions. All right. So far we have added the mortal classes, and we have also make the relationship between the entities. Now I will see you in the next lesson. 45. DbSet and Migrations: in the last lesson. We have added the mortals, and now we're going to register that, Devi said. Properties off mortal classes in the cinema db context class. So let's go to the data folder and then let's open this cinema devi cortex class. Then, as you can see that when we worked with the movies class earlier in this course, then we have to destroy the Devi set off movie. Similarly, this time we'll also add two other diesel properties. One is for user and the second is for reservation. So let's add these properties and then it appallingly all right. Now let's go to the movies controller and let's copy this code and see it. Some of us later in this course when will upload images who have a baby, I then we need this court. We have already covered the image uploading earlier in this course. So this time I'm going to save this court so that weaken it is use it later, and right after that we can't delete this who is controller? Because now we're going to make our FBI from cigarette, and that's why we need to delete this controller now. We don't need that data vis that's present in the secret server Object Explorer. So just the little bit of this, because the state of this will just continue the movies table that we have used earlier just for testing purpose. Now we can took eight a database again from these model classes that we have added in the Models folder. And I told you earlier that locate a database and schema we need to approach is the one is disused. The date of his daughter, Ensure created, mattered in the start of file, and the other is migration. So we'll go ahead with the migrations because maybe in the future will add further properties inside these moral glasses. As you can see that our project only contains Stop Migration folder, which of course, is unnecessary because we have deleted the data vis. And now the magician's better present here are useless. So we'll delete this folder. That's a list of my gracious. Okay, then let's go to the package manager console and dear well, at a magician and there it initial create. All right, here we go. This migration has been added. Now let's try to look like a database schema from the migration stripped and for this purpose lets you start. Doctor did all this? Come on. And here we go. Now, if you go to the sequel server object explored window, refresh it. Then this time we'll get ever did obvious here. And if we expend this, then we'll get all the tables that we need to make our FBI. All right, so that's all from this lesson. Now, I will see you in the next section. 46. Security Overview: security in itself is very complicated and tricky. Topic. I'll try to explain how we can achieve it in v b p i. When we plan to create an enterprise level application, especially, you want to take it off A temptation and authorization. These are two techniques and makes her application secure in our case makes our Web PP. I even more secure. A temptation is all about identity, often and junior. It's about validating the identity off a user who is accessing our system that he is attempting gated enough to use every sources or not. Does that, And you have a valid credentials to organiser systems. Good insurance can be in the form of user name and password. Well, just that token based attempt occassion techniques to understand how we can achieve a temptation in VEB. FBI. On the other hand, we have a tradition. Well, authorization should be considered as the second step after authentication to achieve security. What an addition means what all permission star attempted Gators user has toe access Web resources. Is this user allowed to access or perform action on that resource? This could be achieved by setting rules and permission for an end user who is attempting gated or can be achieved through providing a secure token using vision, and users can have access to other services or resources. So in this model of our goal is to secure the rest. FBI's Why token based a temptation. All right, So from the next model, we're going to implement the authentication and authorization inside our FBI. See you in the next model. 47. Register Method: In order to secure the V p p i. We need to add a controller where we can write to the destroyer and logging mattered. So let's go to the controllers folder And there I would add a new empty controller and name it Users Controller. Now inside this users controller we're going to write a private field off Cinema Devi Context class and then we'll add a constructor and passed the cinema db context object and then assigned this object to this field with this underscore db context, we can pick the d visit properties that's present in the cinema db context class. Well, we're interested to pick this you this property. All right, now this guy, I met it inside. They do this controller and limit the district. This air distributed iss used to the destroyer are sign up the user. This is basically a post battered. So we'll add is two db post attributes on top off this matter it and then pastor you the object in this mattered along with the from body attribute no, later in this course will add the locket better. That will also take the object. And earlier in this course I told you that if the perimeters are saying in the action matters, then we need to add attribute. Roti. So it's best practice to introduce the attribute roading. So let's add the action talking here or drop off this matter it. Now let's suppose we have t methods that take the same parameters now, instead, off writing action token on all these methods, it's better to write. The action token along with the road is rural, So let's leave of the action talking from here. And let's add it along with the Road Europe. Now let's see if we have a user with the falling evil inside the databases. And meanwhile, another user want to register our sign up with the same email. Well, as you know, that evil address for each user is unique. I mean, nor to users can have the same evil address. So how we will restrict the user if he will try to register with the same evil address which is already present in our deliveries. Well, let's use this db context and pick. This is a property. Then who's used A were to check if to you the email that's present in that it ofhis nearly equal to the you. The evil that's coming from this object and then lose used a single or before method here, which will return only a single element if there is a match phone and another value. If no match found, Denville store their cell in a variable, and we're gonna name it judo with same email right after that. Messick If the user with the same evil is not equals to know, then who turned the bad request and passed a full message that is, user, it seems he will already exist. House. Well, just other user. And for this purpose, let's get an object off user class. And right after that, we'll pick the properties off you the class and assigned the data that rule pass from the body off the request. So let's use the name property equals then use this user dot name, then just the evil property equals. She was a dot email. Similarly, we gonna use password equals user dot bastard property. No, By default, every user who will register with help off over the FBI will be his user, and we will assign a user role to the registry user and only the date of this admin can change the rule. I will explain you this role based authorization later in this course. But no, let's set URL equals and then assign Ah, hard coded value. And we pass here users. Basically, in our upcoming lessons, we will add the role based authorization and according to the role based authorization, the users are allowed to access our client side off the application, and the arguments are allowed to access the admin side off the application. All right, now, let's try to insert this you the object inside the date of this and for this purpose, let's use Devi context Art Judas, poverty that comes from this cinema difficult this class and then just add this you the object here right after that. Let's see if that changes while see if changes mattered. And, as you know, that this is a post request and what's the record has been added. Then bulletin the 21 started scored, and for this purpose, let's use the status scored matter and then wound past status course class, resulting in space for this. And then pick the 21 created status coat. All right, now, let me get this application and let's go to the postman. Now I'm gonna use the road to, you know, to exist are do this controller. All right, We're going to issue a poor Seacrest. So let's dance. That needed to be worked to post and then in the body off this request. Well, possum descended. I like name. He will pass it now. If we issue the request, then we'll get to one satis coat. It means our racket has been added. Now, let me go to the sequel server, Object Explorer, and refresh it. Now, if you open the Jews a stable, then inside the stable, we have this record that we have added while postman? No. In the next lesson, let's try to hash this parcel It 48. Hashing Password: in the last lesson. We have created that record while Destry Matic. Now, let me tell you that when we passed the password than password will go to the database in a plain text former. And suppose if someone will get access to our database that he will get a Prosper's off all the users. So it's really a bad practice to put the password in the database in a plain and clear text form it. So what's the solution for this? Well, well, first hash our password that will store it in a database. All right, so let me go to the new it packages for solution. And just it's all this new package, which is S P net core door attended Gatien dark plugging the stock. It is physically shoes to secure the FBI and has the faucet. This practice has been installed. Now let's go to the get a page off this package. Then let's go to the documentation off this package and here's you can see that this package will be used to secure the FBI and two has to pass it. Let's go to the hash spots for documentation, and here will get a nice documentation off using this package. Well, let's see. Your password is apple went to T semi colon, and when you add despots food, then this hash mattered will convert your passport to the falling kind of string, which is different for every password. Also, every time we have the same password, then we'll get differently. This line is basically for the destroyer or sign a matted, and this line is used when we use the logging method. Now when the user will try to log in, then he will provide the password and this very formatted well, master your password with the history. If it's mast, then the juicer is allowed to use the resources. So let's start with the hashing boss wit. Let's copy this line and go to the juices controller now inside that it discriminated. You can see that we have added the password in plain text. Now let's that this users door pass it in this secure password Hasher helper thought Hashmat it and this one line will convert the plain text, form it into history. Also, we need to resolve the next piece. Okay, now, I never did this application, and this time let's try to the district amuses air, adding, That is the name email and password. Now let's issue a request. And here we go. The record has been added. Let me switch to the user stable. And if you confess the table, then we'll get unusual record. And you can see that this time the pasta is in the Hester string. Former. All right, now let me go to the Postman. And this time it's at unusual record with the same past it All right, here we go. The record has been added. Now let's defense the user stable. And this time you can see that we got a different hashching. Although the password for these two users are seen, the casting is different, which is a beauty off this new APP package that we have installed. All right. No, I will get you in the next lesson. 49. JWT Overview: in this model begin to explore the jade ability. Are Jason Wept? Open are also called dot. So what is gentility? Well, Jason Rep tokens rjm duty on an open standard, and that means anyone can use it now. Why we need Jeddah. Pretty because Jenna grittiest usedto securely transmit information between do bodies and why people prefer generality because it's digitally signed. And it means that the information is verified interested, and there is no alteration of data between the transmissions. All right now, what's the structure off? Dead ability? Well, Jason wept. Ogan Argie Dignity consists off three parts. Let's suppose we had the falling Jason ripped open that consist of three parts. The first part with regular the second part with Purple Girl and the third part, the dark blue color. Well, this first part is the header, and this second part is called Pay Load, and this third part is the signature. Let's first explored the header. Well, Henry will look like this, and it suggests an object, and it's simply tell us what's the name off algorithm that was used to Jeanette. A token and this type feel tell us that what's the type off the token. Of course, the type off the token is Jada Beauty. Then comes the payload. The payload contains the claims. Know what is claims? Well, cliffs are the juicier detail and additional matter later, like expiry date off the token and grant, I passed with etcetera. Then comes the signature. Well, it's the most important part. And there we need to pass the header on the payload. Well, our handle is one caffeinated with the bay load, and then it will just a secret key and generate a signature by using the algorithm. All right, this signature provides more security. So after combining all these meetings, we'll get the gentility. Are Jason wept? Open. Now let's explore how JWT works Sports B of a client and the server. The client wants to access, um protected Did our on the server. But the seven knows that plant cannot be, Does it? The server only wants to give the data to the trust 40 clients. So our client send a request to the server along with the credentials to verify who it is. And then if the client data is valid, then the server would accept this dinner and then the several get a token. And this token detected our client No. The next time. If the client wants to excess data sources, then he will just send the token along with the A P A request. And our server will check whether this token is very fight. If it's verified and has not been tempered with, then the server will grant resources to the client. If the token is not valid, are tempered, then the server will simply return the UN authorized message to the client. Now we're going to implement the authorization inside our SP. Doctor gored the FBI. All right, so that's implemented authorization in the next model. 50. Implement JWT Support in Net Core: in order to secure the FBI, we need this new package that is SP that core door a temptation dot plugging all right, But we worked with just tell you their matter Then we have installed this package for possible hashing. Well, we'll use this packet again to genetically Jada Beauty or Justin worked open. Let me go to the documentation off this package. We're on the Get a pitch. Let's go to the documentation pitch and they're in this home page. It's mentioned that this package is used to donate the jade ability or disinfect open why identity? And it's also used to ask the possible Let me go to the at Indication. And then all the steps are defined, which we need to secure our baby p I. So let's start with the Step One, which says we first need to install the new Good Package Insider project. We have already installed this package. Then, in the second step, we need to copy this code and place it in the Configure Sources method, which is present in the startup door CS class. So let's copy these lines of court and then discarded are started dot CS file and inside that configure services method a space, this court. All right, then back to the dugout condition and in the step tree. It's mentioned that once we add the court in the configure services mattered, then we need to add the's name spaces So it's copied these name spaces and then Jim back to the studio and the strike to import these new spaces in the suburb door. CS fight. Now, after adding these names faces, if we will still get a better, then we need to add this new package. So in the new package, manager, just search for this packet and then install it. Now that's good to step forward. And there s mentions that once we add the name spaces, then we need to add this after use a temptation in the conf ear method so that we can use the interrogations. But nor does that we'll add this Abdullah a temptation before outdoor authorization. Otherwise, our moderation will not work properly because authentication always comes first and then the others incomes. Let's copy this line, and then in the start of class, it's good taken, fear mattered and just business line before Abd or use our tradition. All right, now back to the documentation, bitch. An industry five. It's mentioned that we need to add thes lines. Of course, in the upsetting start Justin fight And this key property is basically used to sign and verify the Justin ripped open. You can update the ski as well. Your choice. I mean, in this value part, you can share some other key if you want, and the excess expire seconds. Property is currently set toe 86,400 seconds, which is equal to 24 hours are one day. It means that over Justin ripped open will be expired after 24 hours. So if you want to increase our decrease that open time, then you can also pass the number of seconds according to your choice. For example, if you want to increase the token time from 24 hours to five d, then just wanted, like this value with five. Put the answer here. Similarly, if you want to decrease the token time from 24 hours to 60 seconds, then pass 60 here. All right, let's copy discord and then just open the upsetting start Justin file and there are going to base the scope. All right. Now, the next steps is that Hughes thes two private feels and then passed I configuration inside the constructor. So we need to follow these steps. This copied these fields, and then let's go to the accounts controller. Well, in our case, we don't have an accounts controller. In fact, we're working with dies, uses Controller in which we will add they were sign up or Morgan mattered. So we will go ahead without you. This controller and there are going to place these fields now once again, just go to the documentation pitch and just copy this meant visit. All right, Now, in the documentation, bitch, Step seven is present. But before implementing this step seven, we need to add a logging method. So let's try to add the logging mattered in the next lesson. 51. Login Method: in this lesson, we're going to understand how to implement the lovin functionality and how to get the Jason who have token. Let me tell you the basics off Logan functionality. Well, we need a logging method which is opposed, request and this matter politic. But your object and we'll just broad juicer, email and password to this user object. Not inside this method we'll get that is a record from the Red Service, according to the email. And if there is no record phone, according to the email, then will return the not phone status code. Otherwise, if the user email is found, then we'll verify the user password. If they use a password and the hash password is false, then will return and unauthorized status court. And if they use a password and the hash boss, what is true then will air the claims and genital organ. So let's try to implement this method well at a matter here, Stand limit log in. Then we'll pass to use the object and right after that, just add an issue to be post attributes on top off this method. No, inside this method will use DB context DOT uses property and then pick this first our default function. In this first under full function, we'll check if the email is equal to the user email. Then let's store it in a variable and then it user email. No me check. If the user email is no, did it then for four are not phoned Status court. Otherwise, if the user is phone, then we'll further verify the password. Another question is how to verify the user password because the password desk present in the database will be in the hast former, and the possible that will send to the object will be in a plain text former. So to solve this problem, we will go to the doctor condition off this plug in and there Let's go to the password has documentation pitch. And, as I told you earlier that this court will be used to verify the password and the hashed password. So let's copy this code and then visit in the logging method. Now this mattered will take two parameters, the password that the user will provide. Why this his object and the hashed stink password that will get from the service. So in this first parameter, let's use this object and then pick the password property. Now, in the second barometer, we'll use the hash drink boss wit. Well, the question is hope to get the hash string password desperate in the reader is. Well, as you can see that if the user exists in the database, then we can access all the records off the user with this. You the email. So let's use your email dot bastard property here. Then we will check if the user password and the user has password are false Dennett and unauthorized status code. Otherwise, the password and hash passwords are true. Then we need to generate the Justin Wept Oaken. Now the question is, heart detonated isn't wept. Open our JWT. Let's go to the documentation off this plug in and there we have already implemented thes six steps. Just go to the Step seven. Well, as I told you earlier, that there are two parts off Jason Ripped Open Header, a Lord and Signature, and in the payload, we basically written user claims like either i d email, etcetera. So let's copy discord and then piss it inside. The logging method right after that resulted in your species now, Mr Off bossing the hard putting evil Address this past email address off the user inside the claims. Then we need to copy this line would basically take the claims and generate the access token this carpet is and visit in the logging method. Now this line village in a the accessed open. But to display the access token, Energis informant will need to add the fall in court. So just copy the code and visit in the logging mattered. All right, now this will it in the falling decent values like access token expires in Duncan type expiration time and token creation time. If you want to return only the accessed open, then remove the other perimeters. All right, You can also attended you the I d so pretended user I d. That's lucky that is user and a score idee is You can name it whatever you want. And then let's use this user email, which basically is used to get all the properties of the user and we'll pick this idea property. All right, let's on this implication and into the postman. We're going to call the logging method. So let's use b p I slash users slash locking, then choose its did he proposed. And right after that we could write some decent data like his email and password. Our dear, when we worked with that destroy mattered. We have used a falling evil and pass it. So let's use the same email, but different Bostwick. And if we if you request, then we'll get for one unauthorized status court because our pasta is incorrect. And that's why we will get unauthorized status court. Now let's provide the correct email and password and isn't the request. And soon we'll get a response in the Justin Former, which basically returns to accessed Ogan Topman type and some other values. You can see that we also got the the idea in this sponsor party. All right, now let's use this excess token in the next lesson. 52. Protecting Routes: in this lesson, we're going to learn or to protect the roads. Let me add a simple controller. Have a at the simple controller just to explain you that concept and delivery. This samples controller will not be a part of our project. And later I will delete this controller. Let me go to the controllers folder and there Let's had a new controller with read right actions and I'm gonna name it Samples Controller Now here we have to get methods. If we run the application and syndicate request to FBI slash samples, then we'll get the data. All right, now let's try to predict Ismet it because it's exposed and everyone can access this matter it So in the samples controller, let's head the authorized attribute on top off this samples controller. And of course, we need to resolve the name space for this authorized attribute. Now, with this authoress attribute, only the ultra shooters are allowed to access this symbols controller and all the matters better present in the samples controller. If we write authoress attributes on top of the controller, then all the mattered that are inside the controller will be protected if we just want to protect some particular matter that Ms It off putting the interest attributes on the controller bulls led authorities attribute wound up off the mat it And if we have been asked to protect the controller but just exclude one mattered where authorization is not required. So we will just add allow anonymous attribute on top off that met it. All right, now let me on this application and let's try to access this FBI slash Cipel's. And if you issue a get request, let this time we got an unauthorized status court, which means we're not allowed to access the get matted that present in the symbols controller that way will protect over controllers and the matter it. But now the question is, how will allow the trusted users did use our peopIe I for this purpose will need gentle beauty or Jason kept open. So let's understand the jail ability or just indirect open in the next lesson 53. Use Access Token: in the last. Listen, we got access token, and now in this lesson, we going to utilize the access token to authorize the resources. So inside a samples controller, you can see that we have added the authorized attributes, which means all interested users can access the matter that's present in the samples controller class. So if we issue a get request to the FBI slash symbols, then we're not allowed to access their sources now, in order to access the get method off symbols controller, we need to use the excess stupid. So let's go to the header off this request and there let's have the authorization header and then well past the access token with the token type. Now what's the type off token? Well, if we go to the logging matter, it then it's mentioned here. That token type is Bueller. So this ad better here and then the skopje this excess token and pissed it along with the token type. All right, we're going to issue the request, and this time we'll get the data. So you see how easy it is to secure the FBI and access it while Jason wept? Okay, I have added this samples controller just to explain you the concept. And once we learned the concepts, then remove the simplest controller and we'll dive more deeper into the authentication and authorization. So that's all from this module Now, I will see you in the next lesson. 54. Role Based Authorization: in this lesson, we're going to start working with the URL based authorization. Well, what is the role based on tradition and why we need a role based off relation? To answer this question, let me tell you, Roll, based on tradition, is basically a type off tradition in which will specify some particular roles. For example, we have two applications. The one which is used to deserve the cinema ticket and other, which is used to tell which user has deserved the cinematic it. So there are two application. The one is for Junior and the others for the admin. Now what if you will allow the Jews, er, disuse, the Edmund side after application? Well, if we hello always user to access the admin panel, then it will be a catastrophic situation because the client, our user can easily see all the information, and he can also modify our movies. Let's take an example off Amazon shopping website. Once you purchase something from the Amazon store, then you just a client site application. And on the server side, the Edmund will check your record. And after all the necessary garments, the Edmund will issue your product. So you agree that the Edmund will not give you an access to the admin panel. All right, so this thing will be achieved. Our URL based relation. Okay, now let's implement their old based on tradition. As I said earlier, we have symbols, controller and, well is used the samples controller to learn the role based on tradition and later, when we'll add other controllers for our movies and reservations, then we'll add the role based on religion there. So right now we'll go ahead with the symbols Condor and there We have to get meditates. Let's say this mattered. Will it on this message, which is hello from the other site? Because this is a stream message. So make the type off this matter to strength and the other get method Willard in this message, which is hello from the Edmund site. And we'll also make their turn type off this matter tow strength. Now we have used the arteries attribute on top of our samples controller. It means that everything inside this controller will not be accessible. We don't access open. No, let's see it. This second get mattered will only be accessible to the Edmund off the activation and the juicer cannot access the second get better. So we'll add authorized attribute and then set the role equals. And there. Well, Ed had me. All right. Now the admin off this activation will access the second get mattered, and any others user cannot access it. All right, let's send this application and simply go to the post there. If we call the get matter off this FBI slash samples controller with there were BV issue the excess Servan. Then we'll get this message Hello from the juicer. Now, if you will try to access the second get method, then we're not allowed to accept this matter. We'll get the status court. Reese tells that the request is valid but were not allowed to process this request. All right, now, how to define an Edmund off this activation for this purpose? Let's go to the register, endpoint. And there let's adjust to a new user. And here we go. The user has been created. Now, if you could you the stable, then you can see that this also as user, not the admin, because in the Judas Controller we have set the rule equals users. It means every person who is trying to redistribute our application will be as user. Now let me show you how to make this user as an admin. So let's say the roll off this user to have been, and we looked right at me here. Just make sure the spelling off the eggman is seen in the database as well as in the samples controller. Currently, the access token that we got is genetic means anyone with a valid exist, Okun can access our EPA and points. But remember, we only want to give access to the user. If the rules are specified inside that, it always, for example, if they're all inside that it obvious is user, then we'll get the access token with you the rules. And if the role inside the service is admin, then we'll get the access token for the admin. So to get the access token with respect to the rules, we need to add something inside the logging matters that's good in logging method and there cool add a new claim, and inside this we'll add the claims for rules and then in the value will pass the role property that's coming from the database all right now let's run this application now in the Postman, I'm going to the logging endpoint and there that strike to provide the detail off the juicer that we have the district. Now let's issue a request and you'll get an access token. Okay, lets copy this excess open and go to the simplest controller. And this time, this ad excess took it off Edmund and simply issue a request. And here we go. We'll get a message here which says that hello from the admin. All right, let me tell you that our admin can access both these get methods. Now you can also to stick the Edmund to exit the matter. It's let's say we will not allow our Edmund to access this first get mattered for this purpose. Let's go to the same bus controller and print off this first get mattered. Let's head an authoress attributes with the juices role. All right, now that users can access this first method and the Edmund can access this second, get Matt it that's on this application. And this time, if we try to access the first get method with the admin access token, then will not be able to access it. Now, the striking log in with user credentials. Okay, let me copy this excess open, and we go to pace this user access token here. Now, let's say we took all the first get matter with the users access token. And here we go. We'll get the data. Now, if we try to access the second get met it, then this time will not be able to access it. All right, So that we can add the rule based on tradition inside the FBI. That's all from this lesson. Now, I will see you in the next section. 55. Movies Controller Overview: in this lesson. We going to start ripping with the movies controller before diving into the court. Let me tell you what kind of functionality we're going to achieve for the movies controller . Well, as you know that we're going to make the rest full FBI for Edmund as well as for the client . It means we need to take a their garments off the client or admit off the application. For example, we will allow the admin to get at update and delete the movies. Oiler, On the other hand, we will allow the client toe only get the movies and will not a lot of client to add, update and delete the movies inside the movies controller. We'll need the falling methods, get movies returned, the movies list, and both the client and the Edmund can access this matter it. Then we have a movie detail Mattered, which tells the detail off the particular movie, according the movie I D. And again, both Edmund and Client can exit this matter it then we have Ed movie update, movie and delete movie mattered, and only the Edmund can access these methods to add, update and delete the movie. All right. So these are the matters that we're going to add inside our movies. Controller, the scrutiny over in the next lesson. 56. Adding Movie: in this lesson, we're going to start working with The Post. Mattered to add the movie record. Basically, this ad movie mattered is a post matted and would use this matter to add the movie record inside the Circle database. The Edmund after application will excess dismissed it. So what I'm gonna do is I'll go to the controllers folder and there let's add a new controller and then pick this empty tablet. Just name it Movies controller. All right, Now, I want to tell you that earlier in this course we have created the movies Controller and worked with The Post mattered, and we have also learned how to upload the images. Now, this time, we're going to use the court as always. First of all, we need to add the private feel off type cinema, Debbie Context. There's all the new space and give it a name that is underscore D context. Now we need that constructor that will take the Cinema Devi context as a parameter and finally we will assign this Devi context to our underscore Devi contexts. All right, we have already learned that must the purpose off this devi context because it's used to excess, the Devi said. Properties better present in the cinema. Debbie Context Class. Now we'll add a matter here for reading movie record, but before adding them at it. Then we go to the movies Controller Court that we have copied earlier. I told you earlier in this course to copy the code for the movies controller, which includes the court for uploading images. Do you remember that? Okay, so according to this court, we have a post matter it which will take the movie class as a parameter. This time, we'll use the same mattered to add the movie record inside the uterus. So what I'm gonna do is I'll copy this both matter and visit here. Just make sure to result in in spaces. All right, so this is the court to add the movie inside the uterus, we will only allow the admin toe xs dis mattered. So just at the arteries, attributes or dog off this mattered and set the rule equals admin. Now let's run this application and go to the postman. Their first of all this used the road euro to access this post matter for adding movie. Then let's say in the s a T v work to post. You know that on the Edmund off the application will access this ad movie mattered. So we'll get the access token after admin by calling the logging request with the admin credentials and then simply copy the access token. And right after that, we'll add Authorization Header Pastor talking type, which is being and based every access open here. No, just go to this form did up. And let's add the key and the value we have the following properties inside the movie class , so we'll add a key. According to these properties and Boston reality offer a choice. Let me quickly add the key and the value here. Now let's add image off the movie. Now I'm gonna issue their crest, and here we go. The request is successful. Now let's go to the movies stable, and there will get our movie record. So that's all from this post mattered for adding the movie. Now, in the next lesson, we'll start over with the update Movie mattered, so I will catch you in the next lesson. 57. Update Movie: in this lesson, we're going to start working with that update. Movie mattered. Basically, this method is used to update the movie record, and it is a put matter it. And we would use this matter to upgrade the existing movie record inside the sequel databases. The admin after affiliation will accept this matter it. So what I'm gonna do is I don't go to the movies controller and their little at omitted for updating the movie record. But before doing anything, let me go to the movies Controller Court that we have copied earlier. Okay, so according to this court, we have a put matter which will take the movie class as a perimeter. We're going to reduce this court. So what I'm gonna do is I'll copy this code and go to the movies controller and there Let's face this court, then let's decorate. This mattered with authorized attribute and said the road equals admit because only admin can access this matter it No, we are going to change shootings inside this matter it This court is for the previous movie mortal class. Now we have fallen properties inside the movie class, so let's send it accordingly. I know you are smart enough to pick the concept, and I'm sure you're aware off what's happening here. All right, so this is the court to update the movie inside the galleries. Now, on this on this application and good the punishment there we have already worked with The Post mattered to add the movies. Now we're going to work with the put matter to update the movie. So make sure to do star out for accessing the movies controller, which is FBI slash movies. And then let's change that is to do the work to put. Then you know that all the Edmund off the application will access. This put mattered to opt in the movie record, which means we need an access token after Edmund and we have already set the access token off the admin here. Now what we need is we need an idea along with this euro, and then we'll add the values here which we want to update it. So inside the date of this, you can see that this is the idea for this movie record. So along with the U L, let's add the movie I D. Then let's try to update the record. All right, here we have changed our values. Now let's issue a put request. And here we go. Now to check whether this movie record has been operated or not. Let's go to the movies stable. And if we refresh this table, then you will see that the record against this user I d. Has been updated. All right, so that's all from this. Put mattered. No. In the next lesson, we'll start over work with the delete movie about it. So I look at you in the next lesson. 58. Delete Movie: in this lesson reading to start working with that delete movie met it. Basically, this matter is used to delete the movie record, and it is a delete matter it, and we'll use this matter to delete the existing movie record inside the sequel database. As always, only the eggman after activation will access this matter. So what I'm gonna do is I'll go to the movies. Controller and dear pulled back a matted for deleting the movie record. But before doing anything, let me go to the movies Controller Court that we have copied earlier August. So according to this court, we have a delete matter which will take the movie idea as a perimeter. So what I'm gonna do is I'll copy discord and then go to the movies controller and there that space this good. Then let's decorate this matted with authorized attribute and set. The role equals admit, because we will only allow the admin to access this matter. All right now, we could run this application and let's go to the Postman. They're under reduced a route, which is a P I slash movies, and right after that, well, said the institute, we work to delete. Now we need the access token, Ford admitted. So we will copy the Edmund exist Ogan and visit here with the token type. Which is better to delete the movie record. We need to pass the movie idea along with this You l So let me go to the movie stable. And there you can see that this is our movie I D. So we'll use the same idee along with this You Earl. All right, then let's issue a request. The record has been deleted. Now, if you go to the movies stable and refresh it that this time we don't see any record and we have deleted the movie record, all right, that's all from the delete mattered. Now, in the next lesson, we'll start no work with the get movies. Met it. So I will get you in the next lesson. 59. Get Movies: in this lesson. We got to start over with the gut, movies and point. But before diving into the court, let me add some data inside the move stable because right now the move stable is empty. So very quickly air some data inside this movie stable while Post Request. All right, I have added some did are inside the moose table. Now we're going to work with the get movies. Met it. Let me tell you that both Edmund and Klein can access this. Get movies mattered. Now let's say when this user will log in with our application. Then he will get the list off movies with some specific dater like movie I D name, language, image, euro and rating, etcetera. And if the usable tap some specific movie, then he will get the further detail off the movie. So basically we will lead to get requests, the one which will it in the list off movies and the other which will er than that detail off the movie. According to the movie I d. Salemme, as a matter here, off type I exit result and we're gonna leave it all movies. This is basically I get matted So let's decorate it with Mississippi. Get attribute because the name off this matter doesn't starts with that. Get give it. So we need to add the action. Duncan, on top of this matter it. If you name this mattered toe get movies, then there's no need to add the action. Tobin here because FBI slash movies very than the movies. Now in our case, to return the movies, we need to call this wrote You're a, which is a B I flash movies slash all movies. All right now let's decorate the spattered with authorized attribute. Okay, inside this method, who's used a code to get the movies as always, to get the record from the leader is we used this TV context. Then we will pick the movies, Devi said. Property stole the result in a very able and then read in the result with the automatic. This approach is good if you want to return all the fields. For example, inside of a movie class, there are so many properties, and according to this design, we just wanted it in. Few feels so returning all these properties is useless and it will increase our distance size. Another question is how to return only these things in the Justin response. Okay, let's do it inside this matter. It Bulls used a link Yuri to get the movies from the database, so we'll just a link in the that is from movie and underscore DB Context art movies. Well, this underscored Devi context. Art Movies is a data set we want to give the did up, and this movie is a rich variable. And then just use the select statement with anonymous types. Let's say we just want it on the movie I d. Name language rating. An image, Ural. So we'll add anonymous Type I D and then picked this bridge. Variable dot movie I d. Similarly well Ed Anonymous type name and then lose use movie dot name. Just like that will be language creating an image euro. Okay, now we'll store the result in a very evil and we go near it movies right after that. Yes, it in the O committed and passed the movies here. Now let's turn this application and good replacement there will add a route Ural to access this all movies method. Now let's copy the excess token and visit here all right, then. If he issued a request, then we'll get all the movies from over database and you see this it off all the fields we have got only specific feels that we need. Now, If you want to give some other names to these case, then it's just a piece of cake. So in the old movies made it just in the anonymous types. All right, now in the Postman. If we issued a request, then this time we'll get different distant keys. All right, let me divert the changes. So far in this lesson, we have worked with the all Moves method, which is basically a get request now, in the next lesson, bringing to work with another get mattered, which will attend the movie detail according to the movie I D. So I will see you in the next lesson. 60. Movie Detail: in this lesson, we're going to start working with the movie. Didn't let it. Basically, this will be a get matter it and this method will take the movie I D. And it turns all the details off the movie, according to the movie I D. That we will pass in this matter so we will add a matter Terry off Time I action result, and that's name it movie detail and passed the i d perimeter off type in teaser. All right, then, let's decorate this Mattered with STB. Get attribute because this is a get mattered, and this matter does. It starts with a get keyword, so we'll add an action toga here now, in order to access dismissed it. Rules used his throat, which is a P I slash movies, slash movie detail noticing I d equals and then will pass over. I devalue if you don't want to pass the coolest thing perimeter here and instead you want to pass the idea along with the Ural just like this. Then you have to add idea here along with the action. Duggan, just like we did in the put and Delete mattered. All right, so the choice is totally up to you. Let's go ahead with this second approach. Now a Road Ural will be FBI slash movies slash movie detail slash i devalue, Then let's decorate. Dismissed it with authorize. Active, Built Now inside this Met it. Who's used? Underscore Devi context dot movies dot find mattered and inside this fine mattered wound past the idea here. Now this will find the movie record according to the I D. That will pass in this fine mattered. Then we store it in a variable and name it movie. Now we check if the movie is no. Didn't the not phone met it? Otherwise less attend the movie with the or committed. Now listen, this application and Sister the Postman earlier in this course we have usedto always mattered to get all the movies. No, let's say we just want to get all the details off this movie. So what do they do is we'll change the road, you know, here and then passed. I d along with this UL. Then issue a request. And here we go. This time we'll get all the movie data according to the movie I d. All right, so that's all from this lesson. No, I will see you in the next section 61. Sorting Overview: in this module. We're going to look at the sorting or filtering in SP. Dr Korn, Web, FBI. So, before jumping into the real studio, I'm going to tell you what basically the sorting is I guess you are already familiar with the sorting. If not, then let me show you a picture. Well, if you look at the only express e commerce website, then it will be clear to you. So I have says that them lapped up in the search bar. And then I have got all the laptops in this list. Heiler. You can see that we have price options at the top off this list. So with this price tag, we have two carats if we click this lower carrot than all the laptops appears in this list . But with the price lower to higher in the ascending order. And if we click the upper carrot, then the latter appears for the price from higher to lower our in their descending order. So that's basically the sorting is so in. The next module will get the sorting functionality inside of Web FBI. All right, seal in the next module. 62. Implement Sorting: in the lost Listen. We have talked a little bit about sorting Now weaken to applied, starting in our FBI so that we can sort our data when we send a get request, let me show you what we can to build. I suppose if the user sent a request with a sorting equals ascending, then this get matter will sort the movies with respect iterating property, and then they get mattered will send the movies to the user in the ascending order means the movies with the lowest rating appears first and as physical down will get the movies with the highest rating. And similarly, if we send the request with certain equals descending, then the get method will send the movies with highest rating on the top and as mystical down. We'll get the movies with the lowest rating. And if the user doesn't specify in either ascending or descending, then the cat matter written all the movies to the juicer. Right now, this matter is returning all the movies to the user, so we need to modify this matter a little bit. So let's add a perimeter in this get method, and this diameter is off type strength and underneath it sought. Right now I'm gonna start the movies with respect iterating property. So we just need to pass either the ascending or descending in the A p a euro as a perimeter and on behalf off that ascending or descending, the list of movies will be returned. No, this Addisu statement and inside the statement, this is a kiss. First, we're gonna check if the case is descending, then rules used a written statement. And inside this, who would use the movies, then call the order by descending function. And inside this we didn't is used the Lambda expression and picked up letting property off movie glass. Then we were just check if the cases in the ascending order, then we will use the same line of court, but with different function now, this time instead, off order. By descending, we was used the order by method. As you know, that there is all this our default statement that will be executed when the case is neither ascending or descending in that case, that if all statement will be executed. So this added false statement and then just use the written statement and passed the movies here. This means if the user will neither past ascending or descending, then he will get all the movies. Now we don't need this written statement, So let's remove this. Let me get this application now movie The Postman and along with the FBI general, let's set the sort equals descending and then just initiate the get request. And so, as you can see that the movies with the highest rating appears first. And then comes the movies with the lowest rating higher if we passed Ascending order in the AP is you, Errol. Then you can see that the movies with the lowest rating appears first, and then the highest movie rating appears. And if we don't pass neither ascending or descending, then the divorce statement will be executed and we'll get all the movies so that basically the sorting is you can apply the sorting concept to any of your SP daughter and corrupt FBI in a similar way. All right, that's all from the sorting section. Now I will see you in the next blessing 63. Paging Overview: in this lesson, we gonna learn what basically the Beijing is in this modern era, when there are tens off data to share and consume, we cannot send all the data in one go are the one consumer we need to slice the data into pieces in this world, every next devices, consuming a PR in some way or another. If we consider the iPhone, it consumes a P I. The Windows surface tablets consumes FBI 100 glasses, consumes a p I The I. O T. Devices also need a P I. In other words, a PR is required and revere with these AP ice, we don't only send a single row off data. We send large chunks off data and to display the state. Are we going to juice Beijing? Well, beating is mostly used on every big website like Facebook, YouTube, Twitter, etcetera. Beijing is not limited to add the number at the bottom off the bitch Facebook and Twitter are using paging with the sacral functionality. Whenever we recycle our webpage, the new call goes to the FBI and it will load the new data for us. Heiler at the time off recording this video, Google issues in the burnt, licked paid functionality. Now, in this course or focus is to implement a paging insider, a p I. We will not do it this front end because this front end design is responsibility off front and deliver. And in this course, our whole concern is without back and deliver it. So let's implement disputing in the next lesson. 64. Implement Paging: in this lesson, we go to explore the pity we're going to use the paging inside this get method. But before diving into the court this big don't arsenal you step by step. First, we'll need to provide the piece number. The purpose off base number is that from which page were you going to retrieve the data up ? Second, we will need to provide a paid size Well, the purpose off base sizes to show the number of records on one pitch, then get all the data from the database and apply the simple skip and take algorithm to get the specific result. So let's apply this one No. One. The first thing that we're gonna pass in this matter is based number, and the second parameter is big size. Then we'll get the record from the service. Basically, this line is used to get the data from the database soils used to skip and take a burden to get the specific result. Normally, when we implement a paging, then we use this line to get the data from the database and implement the skip and take other time. But as you can see that we have also used the sorting functionality inside this method. So this time we'll change our court a little bit. Let me quickly add the skip and take Albert. Um And then I will explain you This court well, first skipped a page number minus one and multiply the result of the piece size and then take the the size. All right, Now, let me tell you the basics off Skip and take Alberta in order to understand the Skip Pantic a great um sports. We have 10 records inside this data ways and instant off sending all the records in one request. We want to send the leader in junks, for example, in the first attempt. If the user is on the first page, then we'll send the five records to the user. And in the second attempt, when he will be on the second bitch, then loose and the other five records. And for this purpose would use the skip and take algorithm. Let's assume that are a juicer is on the first place. And he requested just five records. So what happens here is this line will take all the records from the database and store it in a variable and Then the call goes to this line in which we specify the page number minus one. Well, if the user is on the first pitch, then one goes here and pay size, that is five goes here. Of course, one minus one will be zero. And if we multiply anything with this zero, the answer will always be zero. Then this space size bill goes here in this take matter, and this whole line will just take the 1st 5 records from the service. Now, let's suppose if the user is on the second page and he requested five records. So what happens here is the piece number that is to goes here, and the peace size that is five goes here now to minus one is one and one multiplied with the pace size that is five. And the answer is off course five. So it will simply skip the 1st 5 wreckers and then take the next five records. So, death statistics off Skip and take Alberta. Now let's apply the skip and take other than with all the return statements. All right, now, in order to understand this mechanism, we need to run this application now inside the Postman. Let's use our road to euro here. And with that, let's use the question mark and add biz number and be size. Let's assume that under a captain data from the first base and on this page, I just need five records. So let's initiate that get request and he'll we'll get only five records. And if we want to get the record from the second pitch, the Dis pass business and do pivotal this time we got the records from the second bitch. Similarly, we can also get the record from the third bitch. If the third page have some records. Also, we can reduce the piece size, for example. Let's say we only want to records on every pitch. Now we'll only get to records on every bitch. So I hope you have got this concept we can also wrote with the Sorting and Beijing simultaneously. Let's say we want to start the movies in ascending order so we'll add the sort equals ascending. And then let's say we just want five records on each bitch and right after that, let's issue a question and here we go. All right, well, we could also do our gold Better. Because if someone left the pace, number and pay size, then we need to return the letter from the first page with just five records. So how we can implement this first reality? Well, just respect the real studio and just applied the no level types with these base number and base size parameters by using the question mark and then check. If the values are not know, then take the piss number and P size values otherwise distinct. The default values for peace number that is one and peace size, that is five. Then let's start these in some variables. And now in the skip and take algorithm, we need to use these variables. All right, this at these here. Now, listen, this application once again And this time, when we passed the pace number np size, then you will see that the data comes perfectly. But when we forgot to add the pace, number, value and base size value. Then again, the data appears because this will automatically picked the first base with five records. All right, so that's all from this Beijing section. I hope you have enjoyed this concept. Now I will see you in the next lesson. 65. Searching Overview: in this lesson, we could explore the search functionality in our FBI. But before diving into the court, let me tell you what basically the searching is. So if you go to the Google and type something in the search bar, then you'll see the list off items appear in the doctor. I suppose if I type the word android, then you'll see that the list off Android searches appears in this list. So that's basically the searching is the same thing is also present inside the Facebook and Twitter such bar. We're going to implement this such functionality in around a P I. So let's don't live in this functionality in the next lesson. 66. Implement Searching: in this lesson, we need to implement the search functionality in our FBI. Let's has, um, deck. That user wants to find some particular movie. Why such bar? He simply tied the name off the movie in the search bar. And if there is a mass phone, then he will get the search results in the list for you. For example, if they use that provide the movie name equals K, then he will get all the movies started with the author that it and I. Soon as he will complete the search, he will get more accurate. Such a zealot. In order to achieve this task, we need a get matter in which will provide the movie name and on behalf of that movie name , we'll get the search results. So let's dive into the real studio, and this is a matter off type. I exercise ELT, and we're gonna name it fine movies, then pass a stink perimeter and do it on images. Movie name. Now let's decorate, disputed with authorize attributes and then decorate. Dis mattered with scdp. Get attribute because this will be a get request. So that's why we need to add a sedative. Get on top of this mattered. Not this matter doesn't start with the get Gifford, and basically it's a custom mattered. So let's add the action talking here now. Excess dis mattered. This will be the route your l now inside this method. Who had the logic to get the data from the database earlier? We have used this. Go to get the data from the database. So let's copy this court and Pistons scored here. Now, let me tell you that in the fine movies visit, we don't want to get all these values. It's it off these values we want written movie I. D name and movie image. So let's remove the other values. All right then, blessed in the or committed and fastest movies here so far, this is a normal get matter and it will it in the list. Off movies No lets you believe in the search functionality. So to implement the search functionality, well, it's just a very class. And then I used the street variable movie dot name property and then we'll pick the built in Foshan started it and inside this starts with function will pass our movie name perimeter. Basically this line will check whether the movie name starts with a key word that will pass in this matter, it or not. All right, now let's from this application and typical inside a postman, we will add the road, Ural Toe xs this matter it and then make sure that STD Beaver is said to be get. And you have to provide the access token to access this request now. Right after that, well is used accusing permit er toe past the moving in value. So let's pass the key word here. And if I send the request, then I will get all the movies starts with this letter. If I complete this letter that's on the grass again, then this time will get more accurate result. Now, it's really easy for us to implement a search functionality inside the terrestrial FBI. Let me tell you that implementing this search functionality is the responsibility off. Rest ap I diaper and showing this to the jeweler interferes in the form off threat replication or mobile application. Is the responsibility off Vega or mobile app? The Ripper. All right, so that's all from this lesson. Now, I will see you in the next section. 67. Reservations Controller Overview: in this lesson, we're going to start working with that reservations controller. But before diving into the court, let me tell you what kind of functionality we're going to achieve for this reservations controller. As you know that we're going to make terrestrial a P I. For the cinema, it means we need to take in their garments off the client as well as the admit. For example, we will allow the client to add the reservation. Why Opposed Request, on the other hand, will allow the admin to get the list off. Reservations, get reservation detail, and the Edmund can also delete the reservation if he wants. So inside the reservations controller, we will lead the falling matters. Both methods, which will be used by the client for reservation purpose, get less ambitious Better, which will be used by the Edmund to get the list off. Reservations. Get reservation details. Matter will be used to get the reservation detail. According to the reservation I d. Delete Mattered will be just to delete the reservation 68. Post Reservation: in this lesson we're going to start working with The Post Mattered to add the reservation. So let's go to the controllers Fuller and let's at a new controller. Then pick this empty template and under name it Reservations controller as always, First of all, we need to add the private field off type cinema Devi context Resolve the name spears and you know the name that is underscore Devi context. Now we need a constructor that will take the Cinema Devi context as a parameter and finally will assign this Devi context to our underscore db Context field We have only learned that was the purpose off this Devi context. Basically it's used to access that Devi said Properties Mr President in the Cinema Devi Context class All right now Bill admitted here for adding reservation Let's have lamented here off type our excel result and under name it boast this post battered will take the reservation glass object as a perimeter So that's positive And of course we need resulting in space for mortals folder Now we're gonna pass this region object in the body off this request So let's head the from body attribute All right, now Let's decorate, disputed with authorize attribute and right after that, let's say that is, Did it be forced? Attribute on doctors, despite it now inside the Post Met it. We're going to consider the data inside the reservations devil. So let's head underscore DB context. Don't Reservations property dot admitted and passed this letter written object here. Then we need to save the changes with the safe changes bettered right after that. Blessed in the status score, which tells us that the record has been added. All right. Now let's from this application and let's go to the postman there. Let's have a Europe for other missions controller, then change the acidity of work to post. Then we'll copy the access token off the juicer and basit ear. Now let's add some descended a hater. If he could literate in class, then you can see that we have to follow properties like no other reason I d. This is a primary key, and we don't need to add it via post mail. It's hard to implement it. Then we have a quantity price phone preservation time movie I D and user I D. So we will pass the folding descend data here. Yes, Boss. Quantity equals one. Then we need to pass the ticket price. Let's go to the movies stable and let's see. The user is going to book the ticket against this movie and that surprised off this movie ticket. So this past, this price here and then the user needs to write his phone number. Right after that, we will pass the reservation time. Then we'll possibly i d and finally will boss that you the i d. Let's go to the longer request, and there in the response, you can see the i d. This past issue that I d. Here. OK, no, that's issued a request and here we go. The request is successful Now. If you could the reservation stable, then you can see that our record has been added. Now let's modify this matter a little bit. We need to pass the exact method mission time inside this method. Soon it's good that post matted. And then let's head reservation object thought reservation time equals, and then use the daytime dot Now, which will pass the except did time. And now we don't need to pass the did time Where postman so inside the postman pestilent the date time LSE. The user is going to reserve the ticket with the falling movie I D. So let's pass the movie idea here and then pass the price value right after that, let's issued a request. This time we have not added the reservation time by a postman. But if you go to the reservation stable, then he is. You can see that we'll get the reservation time value. So that's all from the post method. No, I will see you in the next section. 69. Get Reservations: in this lesson, we're going to start to work with the get reservations and point. Let me tell you that Onley admin can access this get reservation method. The admin off this application will get the list off relations with the folding data like Reservation I. D. Casper name, movie New and Preservation time. And if the Edmund will further click on any specific record, then he will get the further details. So basically, we will add to get methods the one which will attend the list off records and the other which will return the record. According to the reservation i D. In this lesson, we will get to get reservations mattered, which will return the list off data so inside that as a recent controller, let's add emitted. After I I actually result and then under a limit, get reservations. Now let's add the interest attributes or drop off this matter. It with URL equals admin, then decorate dismasted with Mississippi. Get attribute now in dispute it well, right or code to get the reservation i. D. Casper name, movie name and reservation time. If we go to the other, isn't table, then you can see that we'll get the other reason I d and innovation time from this table. But the question is how to get the customer name and movie name from this table. Well, we have shoes. Start user i D and movie idea here, and these are the foreign keys in this table. And to get the movie name and Casper name are using the values we need to use the joints. Let's explore the joint. Let's see, we have two tables. One is for adoration. Second is for movies, and the third is for juniors. There isn't recent stable contains some data like other Asian I D. Rather is in time and the foreign keys you the i D and movie I D. They use a stable. Contains data like User I. D name and email and the movies. Civil contains the falling guitar like movie I D movie name. I'm it. Now. We want to keep the data from these details so we'll use joints. The basic Centex off joints is that we'll select the leader, set off first able, then rules used the joint keyword, and right after that, we'll select the data set off second table, then lose use the own. Give it. And here we need to set what GT juice to try the tables. First we'll join the reservations and there's user stable and then will further joined the reservations and the movie stable. Who is used to you? The I D Key because it's common in the reservations and they use a stable. So we will add to the idea off another mission. Stable equals U that idea off users table. Then we lose use out of the joint. And first we'll get the data set off movie stable and then once used a movie I d. Key because it's common in the reservations and the movie stable. So we'll add movie I D. Off another vision. Stable equals movie idea off movies table. Then who's used? The select statement edited the valleys. In our case, we want to retain the values from these two tables. Like you. There's movies and reservations. So we were than the values from these two tables in a single request. While joints now back to the studio and inside and get her the nation's battered Will you still inquiry to join the reservations users and movie stable? Well, we have already explored the Centex off joint. So let's use this inside the get reservations. Met it. First. We'll select the data set off the reservation and then who's used the joint? Give it and select the data set after you. The stable then used their own. Give it. And here we need to check which key issues the joint, the renovations and they use a stable. Let me go to the other recent stable, and you can see that we have this user i D. As a foreign key, so we would use the user I d off another division. Stable equals. Use that idea off view. There's table, all right, then we'll join the reservations and the moves table. So let's select another data set for movies, and right after that, who's used to own Give it. And here we need to check which key to juice to join the reservations and the movie stable . So if we go to that led in recent stable, then there you can see that we have this movie I D. As a foreign key. So we would use the movie I d off reservation. Stable equals we I d off movies table, then who would use the select statement with a nervous type. And here we're gonna add parameters, which we want to get, so we'll get there in a recent I D and reservation time from the reservation stable. Then we'll get the customer or you the name from the user stable. And right after that we'll get the movie name from the we stable. All right, Then we'll store the skewed herself in a very able and name it reservations and finally blessed in the okay matter and pastors reservations here. All right. Now I'm gonna run this application and let's go to the postman. Now just sit there out zero to access this get mattered off this another nation's controller. Now let's go to the logging method and they're under issued a logging request with the Edwin Credentials, and he recorded excess token after ed me. Let's go a bit and then we'll pass this excess talking here to excess that get reservations mattered. Now let's issued a request, and you you can see that we'll get the list off reservations with the falling values. So we have successfully got the data from three tables where joints. All right, so that's all from this module. Now, I will see you in the next lesson 70. Get Reservation Detail: in this lesson. We're going to start over work with the get Lewis in detail and point the admin off the application will get the reservation detail. According to the reservation, I d. That he will pass in this matter. When Admiral passed a reservation idea in disputed. Then he will get the falling. Did our? Then we tell you that this get reservation detail mattered is almost similar to the get reservations. Met it. So what I'm gonna do is file copied Ismet it and visit here. No. First of all, let's brilliant this matter toe get hurt innovation detail and then this mattered will take the other mission. I d Now in its past, I d along with this This did it be get attribute so that we can access this mattered. Why are falling out All right now inside this matter it the court will be pretty much similar. We get to kill the data from three tables. But there is one more thing and that is this time will allow condition here and check whether there is a recent I D off reservation table is equal to the reservation. I d. That will pass in this matter now with this condition this mattered will only return the record against this reservation. I D and we will get a single record Instant off the list. Let's say we want to get the fallen descendants. So inside the select, we can pick the data according to our choice. Well, Mr Data that we want to get from this request. Okay, now that's from this application. And let's go to the postman earlier when we send a get request. Then we got the list off reservations. Not this time. Let's say we want to get the reservation against some specific record. So it was passed. Another reason I d along with this jewel. Now, if we issued a request, then this time we'll get the little according to the reservation, I d. No. I want to tell you that we will always get a single record. When we passed the reservation, I d. But you see, we getting these scare records, we don't want to get these scare records here because right now we're only getting the single record. This scare record is useful. When will it on the list? Off reservations. In our case, we just water it in the single record. So what we're gonna do is we'll sleep, stood out with a studio and there let's wrap the security in the apprentices, and we would use the first our default method and this matter very than only a single data set. Now, let's run this application What's again? And this time, if we send the request against this reservation, I d. Then we will not get the scare brackets. All right, so that's all for this module Now. I will see you in the next section. 71. Delete Reservation: in this lesson, we're going to start working with that delete elevation mattered. Basically, dis mattered. It's used to delete the reservation, and, as always, only the Edmund off the application will access this method. So what I'm gonna do is I'll go to televisions controller and there will, at a mattered for deleting the reservation. We have worked with that delete request many times in this course. So this time it will be easy for us. Now isn't off writing all the cord from scratch? We'll use the court from the movies controller class. So if we go to the movies controller class, then here we have delete mattered for deleting the buoys. We will copy this better and then basic here inside the reservations control a class. Now, Will it change a few things inside? This matter it first of all, let's pick the reservations. Deby said Property here instead off movies because we're going to find the data inside over reservations, they will. All right, then we will read in this variable to preservation. Now we will check if television is no then wouldn't that not phone matter otherwise would use the reservations? Do said property here and passed this reservation. All right, so you see how easy it is to add the functionality for military Quest. Now let's run this application. And in the Postman, let's say the admit after activation wants to delete that innovation against this resolution, I. D. So the admin was simply had idea along with the General, and then set the institute provoked to delete. Then if there had been issued a request, then the record will be deleted. The reservation against this I d. Has been deleted. So that's all from this lesson. Now, I will see you in the next section. 72. Create Azure Web App: in this lesson, we're going to create the injure Zepp app to complete this lesson. Make sure you have set up your markets off azure account. If you have a Microsoft Azure cone, then just open it now. Inside the Azure portal, just click on. Create Resource option. Just good, effectively select of it that now just a subscription that would, by the fourth Max off measure will pick the default subscription level. I have a studio enterprise subscription level. You may have a different subscription level, depending on the nature off. Your about. Then create a new source group are so scope is logical container into which will put energy resources like databases, applications, etcetera. The source group is like a folder. Just give some user friendly name to your source group. You can name it whatever you want. Once you get there social, then you need to give a name to your application. Remember your of the application name will be unique, nor to users have seen the application name. Just give some unique new once you provide the activation name, then just licked our runtime step basically in the runtime. Steck. We want to tell or replication that what kind of platform were targeting? That's check what gotten poor version. We is using insider project, So just go to the studio and right Click on your pet or V P P I, and choose properties inside the activation properties. You'll get your dark could feel it At the time of recording this course, I'm just in the falling daughter core version. Maybe you was using some different doctor core Russia. Let's get back to the azure portal. And there, if that arctic or version that we is using is available in the runtime stack, then selected. In my case, it's not present, so I will select some other dot Gore version and later once will get a replication. Then I will also show you how you can update your daughter Corvette Baby, I inside MCAS off measure. Now just click on review and create Click on the Create Option, and this will create your Web application. Once the stepped up deployment is completed, you'll get a success notification. Just click on the picture dash boat, and this will be your rep gap inside the azure dashboard or home supreme. Now we can access our vet there from as your hopes agreed. So just click on Java application. Then we need to download this get published profile in which the confusions are present. We need this fired when we will publish the weapon P i to Microsoft Azure. Now we have created our reputation and in the next lesson we give to create over as your secret server and database. So I will see you in the next lesson. 73. Create Azure SQL DB: in order published of L. A P I. To Max off measure, we need a few more things we need to get Msde SQL database inside the Microsoft measure. So let's start with the Azur sequel that office disk. Click on sequel databases. Depth the egg option to add the sequel it of this. Just use the same this so scope that we have created in the azure Web application. Give some user friendly name to your database. Then we need to get our server in which will add or deduct this. So expect this. Create a new server. We will put our database now just given them to the server. Then add the server admin log in name and password. We'll need this admin log in name and password when we try to access the azure secret of it . Also, just in years location where you want to put your server, you confuse the nearest location as per your choice. All right to stop this review plus create option. And this will create a database inside the Microsoft measure. Mediations, because this will take up to five minutes now, once the deployment is complete, that you'll see this message just open the notification and just tap on the two dash boat so that it will be never date of this to the trash boat. And next time, it will be easy for us to open our database from the dashboard now. Just opened it abuse. Now, once you open that it is, then you will see the phone kind of interface. You need to set the server fireable because if we don't set the server fireable, then are as your secret service will not access the Azur replication by default. The Allah as your services options is off. So we need to turn it on. Once we turn on the all as your services, then just save the changes. Soon we'll get a message which says that are sever. Five other girls are updated displaced. Okay. So far, we have created the azure reputation. And as your deliveries now we can to publish our VEP FBI to measure. So stay with me because I'll be right back in the next lesson. 74. Publish Web Api To Azure: so far we have created or as your brother and Secret service inside the Azur. Now we're going to publish our dot kovak ap I to Max off Asher. I see No, that earlier in this course when we worked with the local database in the sequel server Object Explorer. Then we have used a connection stream. But now we get to work with the Azure sequel databases. So this time, with the connection, string off as your secret little Miss So just opened the actual secretly Davis. Then just click the show did a disconnection stream. Then you need to copy your date of this connection. Seem right after that inside of your studio. Just open the start of dot CS file way have she was Dr Nexus Stream. But the connections thing that we have used is for local it service. So we don't need this. Rather, we will air the connections thing that we have copied from Azure portal just removed the local database connection scene and Mr Connection string off as your sequel databases. If you don't want to add the connections thing in this started dot CS file, then you can add the connections thing inside the upsetting start. Jason file. So let's open the upsetting start Justin file. And inside this file, let's add that could existing in the form off Jason. Let's add the connection string and then in the curly brackets, wiggle to add the distant key value pairs. Let's add a key. You can name it whatever you like. I'm gonna give a falling name to the key, which is cinema db Connection. Now in the Value section move boss of a connection state. So just make sure you have copied your actual connection string and then base it here. Now, once you add the connection stream, then make sure to provide the user I D and password in the user i d. We need to pass the admin, logging him and in the past food. We need to add the password that we have said when we created over as your sickle, that abyss and server. Now let's go to the starter dot CS file and there let's get rid off this connection steam. As you know, we have defined their connections thing in the F sitting start descend fired, so to access our connections thing in this start a file. We need the help off this configuration interface. Any time when we try to access something from the F settings file, we need this configuration interface. So let's use this configuration dot Then call the get connection, sing Matt it. And in this message with bus over connection, Stinky, which we have written in after these files. So I'm gonna copy disconnection, stinky, and then base it here. Okay, let's close all the files and now we begin to polish or v p p I to max off measure. So in order to pull Mr V P. P, I just right click on the project and click publish. The bullish option will open the falling dialogue we need to import style. Choose the publish profile that we have dollars earlier when we worked with the Azur. That application once we just a published profile Denville studio will detect our that pura . Now we need to choose this added deployment mode. There would need to change a few things. First of all, let's go inject this apply migration checkbooks, Then copy your connection string bastard, You their I d and password and based on existing here Now you'll see that we have this framework dependent deployment moat, we'll change this to self contained. Now let me explain the difference between the framework dependent and that self contained deployment. Well, at the time of recording this video, Microsoft Azure only sports doctor core 2.1 and Dr Core Cheaper and one. And currently it doesn't sports the doctor core. Version 5.0, in future, Microsoft will definitely at a dotted core version five inside the Microsoft measure. But till then, we need to go ahead with the cells. Contain deployment boat. Now what is self contained? Deployment moat. In order to understand the self contained deployment, we first need to understand the framework dependent deployment well in framework dependent deployment was simply Kate our azure Web app and provide the exact version in the runtime stack that we is using insider WEP e. P. A project in favor of dependent deployment. The assemblies, which need to run your rep FBI on the targeted machine are present, and you just need to upload the source scored and some sporting packages, which your court it's using now. On the other hand, if you talk about self contained deployment, then it means the assemblies, which needs to run your project in the targeted machine, are not present, and as a result, you need to upload the assemblies and the source sort. But such contained deployment takes more time as completed, a favor dependent deployment because in the self contained, we need to upload all the assemblies on the Microsoft Azure portal now. If he was using the doctor core version, which is not present in the Microsoft measure, then go ahead with the self contained. Otherwise, continue your work with the fame of dependent deployment. I look over the self contain because, as he always said, at this time, Dr 5.0, is not available inside the Microsoft measure. All right, save it and click publish, then you need to wait for a few minutes during that deployment. Just make sure you're connected with the Internet, and here we go Now, once the deployment is successful, then real studio will lord the Web application inside your default Web browser. So far, we have published our rep E. P. I to Max off measure No. In the next lesson, we'll open the SQL tables inside a Microsoft Azure, so I will see you in the next lesson 75. Azure Query Editor Preview: earlier in this course, we have published the FBI to Marcus off measure another thing to view over data inside the azure secret office. So open your actual sequel, that obvious select acuity editor preview option. And on the Russian side, we need to provide the same admin log in and password that we have used during the creation off as your sequel, server and database. If you conditions are correct, then you'll get all the tables under the tables. Option not in the next section. I will show you how to add data inside these tables because currently, these tables are empty. All right, now, that's all from this lesson. No, I will see you in the next section. 76. Insert Data Inside Azure Sql Db: in the last lesson. I've told you how to access these tables inside a Microsoft Azure. Not these tables are empty. And let me show you how to add data inside thes tables. So just go to the postman. And there, there we go to the district endpoint. And this time, instant off this local host. We need to pass our azure web. You're here. All right, then. I'm going to the distress, um, user. And here we go. The status Go to a one created. Now go back to the azure portal. And if we refresh the table, then we'll see over do that here. Now, let's made this user as an admin. So in the role, let's stay in the studio to admin and let's see it. Now we can use this log in and point to get the access token. All right. Similarly, we can add some other user virologist endpoint, and if it's respected the azure portal and refresh it, then we'll get the needle here. So that way we can add the later inside the azure sickle Davis. All right, that's all from this lesson. Now, I will catch you in the next section. 77. Create Api Documentation: in this lesson, I'm gonna show you hardly every sportsman to ease the stress off generating documentation. Let me show you how we can add FBI documentation. So I'm gonna do is palaces to the postman and their other tests, all endpoints that we have created. But before this, let's start our collection. Well, if you're not familiar with the collection, then I will tell you that our collection is like a folder in which will add our FBI endpoints it all of this to grow our request so that each AP resource can act like a fuller where we can save similar and points in order to get the collection. Just go to that collection step and there we'll click this new collection. Now we need to provide the name off Aware collection. You can give some user friendly name that represents our FBI under limit cinema, FBI. Then this description is optional. If you want to add some message in this description, then you can have it basically that you give this a P documentation to some developer. Then it will be easy for him to know what this EPA is about. So let's there some description here now let's get this collection. As soon as we will create this collection, we'll get this folder here now in the cinema FBI. We'll add our e p and points for users, movies and reservations. Controller. Let's start with that. You this good daughter? Well, in the Judas controller, we have these endpoints, and now we're going to make a via duct condition from these and points. So let's start over right. First of all, we'll start with this register endpoint, and just make sure to add your own that a Ural a lot with this endpoint. All right, then we'll click this save option, and this public appears, which includes our AP and Point Ural and the description. The description is optional, but you can provide the detail off the end point if you want. Now, before saving this egg point. Just good. Afford er and limit users now in this US fuller who will save all the endpoints off users controller. All right, let's see it disliked this the district endpoint. You need to get the AP the recommendation off. All the end points off the use this controller maybe speed up that things and I have added all the uses controller and points in this You this folder? No, I just like you. This controller. We could test the movies controller. So let's start with the falling and point off Movies controller then dressed this save option and now advocates a folder inside this collection. And there it movies. All right, let's save our endpoint in this folder just like this endpoint, You need to add all the endpoint off movies controller inside this movie's folder. Okay, here I have added all the endpoints off movies controller. Now, let's go ahead with the reservations controller. Let's start with the folding and point off reservations controller. All right, then press the save option, and right after that, let's get a new fuller inside this collection and we name it reservations. All right, Now let's save this endpoint in this reservations folder, okay? You have to add all the endpoints off other races controller inside this reservations folder. Now, once you had all endpoints inside this cinema collection, then go to the options menu and simply published the documentation. If you are a new postman user or have not logged in, then you have to get a postman account. So let's get a postman account in the next lesson. 78. Publish Api Documentation: in the last lesson, we have added the endpoints inside a collection. And if we try to publish this FBI, then postman requires an account. So let me set up my postman account. Once everything is OK, then we're going to publish this FBI. If you press this published doc option, then soon our Web browser Ville open. Now let's publish this collection. As soon as we click this published collection option, it will load the AP documentation link. And by using this link, we can access our FBI documentation. Let's click on it and we'll get our AP Documentation Page, which shows our FBI documentation. You can see this. We have this you this folder which contains the endpoint off. Use this controller. Then we have movies and another vision section, which contains all the endpoints off movies and reservations. Let's click some endpoint and you can see that we'll get all the information about this endpoint like What's the General? And what descended at this end point Will Dick now on the right inside and along with Peter Greste, we have this example request. Let's say our Klein wants to consume this FBI in C sharp black phone that he could simply pick this see shop option, and he will get the sea shop code off consuming this FBI. Similarly, if the Klein wants to consume this FBI in nor Gs, then he could pick the Nordea scored. All right, that's all from the AP Duck Condition. Now, I will see you in the next lesson. 79. Share Api Documentation with the Client: in the last lesson, we have published the a P A documentation. Now I want to show you how you can share this. AP Documentation with the developer are your client. Let's say you made an e p documentation for your client. Now, your client wants the a p a recommendation because he wants to test the A P A and points. So what do you have to do is you can share this link with your client. Let's see what the client will open this link inside the web browser. Then he will get this A B A documentation pitch. Now, let's see, Your client wants to test the EPA endpoint, so he simply click this run in postman option. And then this public up years, which tells, declined to open this a paedo commendation with the postman. All right, if the client has installed a postman tool and click this option, then this will load all the endpoints inside a postman off clients machine. All right? No, the client can access all the endpoints and destined points off his choice. Now, in the next lesson, I will show you how to embed this run in postman button inside your rep KP project. So I will see you in the next lesson. 80. Embed Run In Postman In Web Api: in this lesson. I'm gonna show you how we could embed this run in postman burden inside our rep AP a project so that it will be easy for recline to get the FBI directly from our website. So what I'm gonna do is just which of the postman and let's click on this collection and that this share option no good to them back there. And you did the court. All right, here's the court for this Run in Postman button. Okay, Now let's go to the GP project. And inside that www root folder, we gonna create an East Evil file and then near it index dot html This just a basic court to start a civil file. Now, in the body off this festival file, we'll add the court that regard from the postman. So I'm gonna copy the court from the postman and visit here, Not a secret. And then we're going to publish therapy P again on the max off measure. So let's try to publish our happy FBI to the edger. All right, here we go. Now you can see that we'll get the run in postman option. Okay? Now, if we want to share the FBI with the client. Then we could simply give the website address to the client and he contest the FBI's inside the postman. All right, I hope you have enjoyed this video, and that's all from this lesson.