From the course: Building Angular and ASP.NET Web API Apps

Unlock this course with a free trial

Join today to access over 24,700 courses taught by industry experts.

Set a user ID when a transaction is created and loaded

Set a user ID when a transaction is created and loaded

From the course: Building Angular and ASP.NET Web API Apps

Set a user ID when a transaction is created and loaded

- [Instructor] Right now, whenever a user creates a transaction, we do not set the user ID. Other than that, we do not filter the transactions by the user ID. What this means is that any user can view any transaction. In this part, we are going to change that. First, when a user creates a transaction, we will set the logged in user ID to the transaction record. And second, when we log the transactions, we want to show only the transactions of the logged-in user. In Visual Studio, we need to first modify the database so it also supports the user ID. Right now if we open tables and then go to transactions, you'll see that in here we don't have a user ID. Now to add a user ID column in this table, we need to first add a property to the transaction model, then add a migration and push changes to this table. So let us go to the solution explorer, then here, go to models, and then find the Transaction.cs. Then we are going to add another property. We are going to name this property public…

Contents