.NET Core — WebApi tips

Ibrahim Jaber
4 min readJun 25, 2021
Photo by Nick Fewings on Unsplash

Building Api with good practices and proper documentation is important for the development life span of API service.

Today, I will walk you through a sample of an API(that can be improved upon). we will build upon that API example and add a couple of features Like Swagger, Async calls to the Database, and so on.

Let Get Started!!.

1-Cloning the existing Repo.

  • You can find the Repo link here

2-Making our Database calls Asynchronous.

As you can see below the methods in the Interface aren’t Async.
we will go ahead and change that to be Async.

a-Making the Interface methods Asynchronous.

  • Making the methods Asynchronous improves the response time where you can run multiple calls simultaneously and, save time instead of waiting for each call individually.
  • Old version
public interface IBaseRepo<T>    
{
List<T> GetAll();
T Get(int id);
int Save(T item);
int Delete(T item);
}
  • Updated
public interface IBaseRepo<T>{

--

--

Ibrahim Jaber
Ibrahim Jaber

Written by Ibrahim Jaber

Software developer | Programming and Blockchain enthusiast

Responses (1)