
Learn to build a real rest web api using C#, SQL, Dapper, and Json, with a database-first approach and EF Core mappings in ASP.NET Core.
Create a new database in SQL Server Management Studio, switch to it, and define a users table with id as an identity column, plus username, email, password, and email confirmed.
Create and relate tables in sql server management studio, including a co-generation table with a six-digit email verification code and supporting user images, contacts, and addresses.
In this lecture we are going to create the project in Visual Studio.
Learn to add Dapper and SqlClient packages to the project using Visual Studio's package manager console, and install them with the appropriate commands.
Demonstrates adding and configuring a connection string in the project for a SQL server database, including local server settings, trusted connections, optional credentials, and enabling multiple active result sets.
The lecture shows how to add an accounts controller to the project, create an empty api controller, and configure a private field and connection string from configuration.
Demonstrate building a SQL Server stored procedure for user registration, including parameter handling, duplicate checks, and inserting into user and cogeneration tables, plus generating a verification code.
Create register user model and register user result model in Visual Studio project, defining username, email, and password, then include user id, username, and email in the result.
Register a user via a secured http post action in Visual Studio, using the RegisterUser stored procedure with dynamic parameters for username, email, and password, returning userId, userName, and userEmail.
hexadecimal is a positional system that represents numbers using a base of 16. it uses sixteen distinct symbols, most often the symbols "0"–"9" to represent values zero to nine, and "A"–"F" (or alternatively "a"–"f") to represent values ten to fifteen.
Don't forget to verify some user's email and to save some user's passwords before hashing them to test sign-in action method.
Implement password hashing in a real REST web API using C#, SQL, Dapper, and JSON, tested via Postman by registering users and verifying hashed passwords in SQL Server.
Create a mail model and send a verification email via api services using smtp, with from email, to email, subject, and body containing the verification code.
Register a new user and send an email with a verification code, then verify the email using the generated code in a real rest web api.
Learn to verify a user's email in SQL Server by validating the email and the generated verification code, and updating the user table's emails confirmed flag through a stored procedure.
Create a stored procedure to sign in the user by validating email and password against the user table, ensuring the email is verified. Throw error if credentials don't match.
Organize your Postman test workflow by creating a collection, folder structure for accounts and registered user, and saving user requests to streamline rest api testing.
Create sql server stored procedure that takes an email, checks the users table for email, updates the code with a random value, and selects user id, email, and updated date.
Create a Visual Studio action method to generate and return a code, update the model and stored procedure parameters, and email the new code to the user via an API.
Implement a reset password workflow in a rest web api using C#, sql, and Dapper by creating a reset password procedure, validating email and code, and updating the user password.
Create an upload image class with a static method that uploads a profile image to the application storage. Then save the image path to the database via a file stream.
Learn to add or update a user profile image with a stored procedure, manage insert or update, upload to storage, and expose an API to attach the image.
Define a sql procedure to fetch a user image by user id and expose it via a get user image api, enable static files, and test with Postman.
Create an API action to delete unused profile images by comparing image names in the database and storage, then remove orphaned files when a user updates an image.
This lecture teaches fixing an issue by deleting unverified users older than three days, first from the cogeneration table and then from the user table, deleting all related data.
Add and update a user's address in SQL Server with an upsert stored procedure handling user id, apartment, building, street, city, postcode, country, and test with Postman.
Learn to retrieve a user's address from database by selecting from user address table where user id matches a parameter, using a web api with C#, SQL, Dapper, JSON.
Course Tools
SQL Server Management Studio.
Visual Studio.
Postman.
Advantages of this course :
- Learning in real app, where we design an API that meets business objectives.
Such way is considered to be a highly important learning process. Besides, it equips you with a knowledge that can be easily extended and integrated.
- Building Database first, this approach give the developer a lot of advantages like protect you from losing data, and easier to write SQL commands.
- Using C#, which is an object-oriented, component-oriented programming language that supported by Microsoft, and the best news that it will be immediately familiar to C, C++, Java, and JavaScript programmers.
And the most famous advantage of knowing C# is the expanded wideness to make mobile applications, web applications, games and more.
- Using Asp.Net Core, a free and open-source web framework developed by Microsoft. This framework allows us to include packages in our application which make it faster.
- Using Dapper, that is a tool which maps your database directly with C# objects. Fast in performance with fewer line of code.
- Using Json syntax, which is fast and readable way to exchange data between the server and our application, it’s actually a text that written with JavaScript object notation..