CREATING WEB API

  1. What is API(Application programming Interface)

>> Simply it is a collection of requests that carry the user requests to database and then if database searches and found the corrected data requested by user then API returns the corrected data to the user.

Different responses like:– 200(success), 400(Bad Request,,didn’t understand what to do due to incorrect syntax), 500(Internal error)

2. Benefits of API

>> Improves user experience

>> Integration(Connects different software applications through which a used can save time and increse work ability)

>> Reusable

One time coded applications can be run in many different platforms. It means we don’t need to code again to create the software application.

>> Scalability

API helps to scalable the software application. It means programmer can change or add or delete any codes in the project.

3. Configuration of API in dot net core

>> Create new API in dot net core.

>> Select dot net core web API template.

>> Install necessary nuget packages(Microsoft entity framework core, SqlServer, Tools, design, swagger, swaggerUI, swaggerGen, jwttoken etc.)

>> Create connectionString in appsetting.json file.

 

 

>> Register this connection string in programme.cs file.

 

 

>> Create ApplicationDbContext and must be inherited by IdentityDbContext(if you want to use identity for login, logout, authorization and authentication in software application)

 

4. Create a demo API(Festivesale)

>> First create entity model.(ProductId, Productname, ProductPrice, OrderDate)

>> Register the model in DbSet.

>> Create interface and define methods.

>> Create service.

>> Implement all the methods in Service.

>> Create controller and call the methods(FestivesaleProduct).

Inquiry now