Registering data services
We have created a data service for our database calls. We now need to register it. But we have created the service as an abstract class, which means we can’t use the class itself. We need to implement other services that will inherit from our BaseService<TEntity, TModel>
class.
First, we can create a service for the Movie
entity, like so:
Services\MovieService.cs
using AutoMapper; using MediaLibrary.Server.Data; namespace MediaLibrary.Server.Services; public class MovieService : BaseService<Movie, Shared.Model.MovieModel> { public MovieService(MediaLibraryDbContext dbContext, IMapper mapper) : base(dbContext, mapper) { } }
The preceding code snippet shows the whole file for the MovieService
class. The class has an inheritance for the BaseService
class, where we specify Movie
and MovieModel
as the generic parameters...