public UserServicesController() { _validator = new CreateUserServiceRequestValidator(); _userServiceRepository = new UserServiceRepository(); _userRepository = new UserRepository(); _serviceRepository = new ServiceRepository(); }
public bool IsUserRegisteredForService(TUser user, string serviceId) { var userList = UserServiceRepository.GetByWhere(new Dictionary <string, object> { { "UserId", user.Id }, { "ServiceId", serviceId } }); return(userList.Any()); }
public Task AddServiceToUserAsync(TUser user, string serviceId) { if (IsUserRegisteredForService(user, serviceId)) { throw new ArgumentException(string.Format("Service {0} already has been added to user {1}", serviceId, user.Id)); } UserServiceRepository.Insert(new IdentityUserService { ServiceId = serviceId, UserId = user.Id }); return(Task.FromResult(0)); }
private IEnumerable <IdentityUserService> GetUserServices(TUser user) { if (user == null) { throw new ArgumentNullException(nameof(user)); } var services = UserServiceRepository.GetByWhere(new Dictionary <string, object> { { "UserId", user.Id } }); return(services); }
public void SetUp() { var serviceProvider = new ServiceCollection() .AddEntityFrameworkSqlServer() .BuildServiceProvider(); var builder = new DbContextOptionsBuilder <AppDbContext>(); builder.UseSqlServer($"Server=(localdb)\\mssqllocaldb;Database=UserServiceTest;Trusted_Connection=True;MultipleActiveResultSets=true") .UseInternalServiceProvider(serviceProvider); _context = new AppDbContext(builder.Options); _context.Database.Migrate(); _repository = new UserServiceRepository(_context); }
public UserServicesController() { _userServiceRepository = new UserServiceRepository(); }
public UserService() { userServiceRepository = new UserServiceRepository(); }