The service class interface

Since we have defined all the requests and response types needed by our service, we are now able to proceed by defining the IItemService interface and its implementation. As a first step, we can create a new Services folder in the Catalog.Domain project and proceed by defining the following IItemService interface:

using System.Collections.Generic;
using System.Threading.Tasks;
using Catalog.Domain.Requests.Item;
using Catalog.Domain.Responses;

namespace Catalog.Domain.Services
{
public interface IItemService
{
Task<IEnumerable<ItemResponse>> GetItemsAsync();
Task<ItemResponse> GetItemAsync(GetItemRequest request);
Task<ItemResponse> AddItemAsync(AddItemRequest request);
Task<ItemResponse> EditItemAsync(EditItemRequest request);
Task<ItemResponse> DeleteItemAsync(DeleteItemRequest request);
}
}

The preceding definition exposes the methods needed by our application. First of all, we should notice that all the functions return a Task<T> generic type. We can also see that all the methods end with the Async prefix, which suggests that the implementation will be asynchronous. 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.104.29