|
| 1 | +using Microsoft.Extensions.Logging; |
| 2 | +using SharpRepository.CoreMvc.Models; |
| 3 | +using SharpRepository.Repository; |
| 4 | +using SharpRepository.Repository.Configuration; |
| 5 | + |
| 6 | +namespace SharpRepository.Samples.CoreMvc |
| 7 | +{ |
| 8 | + public class UserRepository : ConfigurationBasedRepository<Contact, string> |
| 9 | + { |
| 10 | + public UserRepository(ISharpRepositoryConfiguration configuration, string repositoryName = null) : base(configuration, repositoryName) { } |
| 11 | + } |
| 12 | + |
| 13 | + public class UserService : IUserService |
| 14 | + { |
| 15 | + protected IRepository<Contact, string> _userRepository; |
| 16 | + |
| 17 | + public UserService(IRepository<Contact, string> userRepository) |
| 18 | + { |
| 19 | + _userRepository = userRepository; |
| 20 | + } |
| 21 | + |
| 22 | + public IRepository<Contact, string> GetRepository() |
| 23 | + { |
| 24 | + return _userRepository; |
| 25 | + } |
| 26 | + } |
| 27 | + |
| 28 | + public interface IUserService |
| 29 | + { |
| 30 | + IRepository<Contact, string> GetRepository(); |
| 31 | + } |
| 32 | + |
| 33 | + public class UserServiceCustom : IUserServiceCustom |
| 34 | + { |
| 35 | + public UserRepository _userRepository; |
| 36 | + |
| 37 | + public UserServiceCustom(UserRepository userRepository) |
| 38 | + { |
| 39 | + _userRepository = userRepository; |
| 40 | + } |
| 41 | + |
| 42 | + public IRepository<Contact, string> GetRepository() |
| 43 | + { |
| 44 | + return _userRepository; |
| 45 | + } |
| 46 | + } |
| 47 | + |
| 48 | + public interface IUserServiceCustom |
| 49 | + { |
| 50 | + IRepository<Contact, string> GetRepository(); |
| 51 | + } |
| 52 | +} |
0 commit comments