Add a test user

- [Narrator] The add test data method in the start up class…adds some test data to the in memory database…every time the application starts up.…We can use the same approach to…add some test users to the database.…In the start up class, at the very bottom,…we have add test data,…and that's being called from configure.…Right above where we're calling add test data,…I'm going to add some new code.…We'll here say, add some test roles and users.…First, I need to pull a role manager…and user manager out of the service collection.…

So we can say app.applicationservices GetRequiredService…of type Role Manager which we need to input from…identity and the role manager will be of type…UserRoleEntity.…And very similar for the user manager…pull that from application services as well…say user manager of type user entity.…Now we can call a new method called AddTestUsers…and we'll pass the role manager and the user manager.…

Now we can implement this add test users method.…I'll use visual studio to generate a stub.…We'll make this static.…

Resume Transcript Auto-Scroll

Author

Released

6/28/2017

Most people have heard of RESTful APIs, but the underlying concept—REST or representational state transfer—still causes confusion. REST is all about modeling resources and how those resources can change. RESTful APIs use this architecture along with HTTP requests to transfer data and changes in application state between clients and servers. This course will break down the principles of RESTful design and show how to build secure RESTful APIs on top of ASP.NET Core. Nate Barbettini answers questions such as: What is RESTful design? How do you perform RESTful routing? How can you build reusable classes to represent resources? What role does caching play? And how do you secure RESTful APIs? He also covers topics such as data modeling, hypermedia relationships, and authentication and authorization. By the end of the course, you should know not only the basics—how to properly use HTTP verbs and return JSON data from ASP.NET Core—but also the best practices for building secure and scalable APIs to serve web clients, mobile clients, and beyond.