public UserController(ILogger <UserController> logger, IOptions <UserServiceConfig> config) { _logger = logger; _userServiceConfig = config.Value; try { var mapConfig = new MapperConfiguration(cfg => { cfg.CreateMap <TandemUser, TandemUserDto>() .ForMember(dest => dest.UserId, opts => opts.MapFrom(src => src.Id)) .ForMember(dest => dest.Name, opts => opts.MapFrom(src => $"{src.FirstName} {src.MiddleName} {src.LastName}")); }); _mapper = mapConfig.CreateMapper(); _cosmosClient = new CosmosClient(_userServiceConfig.UserDataStoreEndPointUri, _userServiceConfig.UserDataStorePrimaryKey, new CosmosClientOptions() { ApplicationName = "Tandem User Service" }); _database = _cosmosClient.GetDatabase(databaseId); _container = _database.GetContainer(containerId); } catch (Exception ex) { _logger.LogError(ex.Message); } }
public UserService(HttpClient httpClient, UserServiceConfig userServiceConfig) { _httpClient = httpClient; _userServiceConfig = userServiceConfig; _httpClient.BaseAddress = new Uri(userServiceConfig.ServiceAddress); _httpClient.Timeout = TimeSpan.FromSeconds(userServiceConfig.RequestTimeoutInSeconds); }
public UserServiceTest() { _userServiceConfig = new UserServiceConfig { ServiceAddress = "https://f43qgubfhf.execute-api.ap-southeast-2.amazonaws.com/", Endpoint = "sampletest", RequestTimeoutInSeconds = 100 }; }
public UserService(ILogger <UserService> logger, IHashService hashService, IAuthTokenService <long> authTokenService, UserServiceConfig config, IDbServicesFactory factory, IViewTypeInfoService typeInfoService) { this.logger = logger; this.hashService = hashService; this.authTokenService = authTokenService; this.config = config; this.dbFactory = factory; this.typeInfoService = typeInfoService; userTable = typeInfoService.GetDatabaseForType <UserView>(); }
public IServiceProvider ConfigureServices() { var services = new ServiceCollection(); //Inject Service and config AddConfiguration(services); var config = new UserServiceConfig(); Configuration.Bind("UserService", config); services.AddSingleton(config); services.AddTransient <IUserService, UserService>(); services.AddHttpClient <IUserService, UserService>() .SetHandlerLifetime(TimeSpan.FromMinutes(5)) //Set lifetime to five minutes .AddPolicyHandler(GetRetryPolicy());; ServicesProvider = services.BuildServiceProvider(); return(ServicesProvider); }
public UserServiceTests(DbUnitTestBase fixture) { config = new UserServiceConfig { MinPasswordLength = 4, MaxPasswordLength = 8, MinUsernameLength = 4, MaxUsernameLength = 8, UsernameRegex = "^[a-zA-Z0-9]+$" }; searcher = fixture.GetGenericSearcher(); this.fixture = fixture; this.service = new UserService(fixture.GetService <ILogger <UserService> >(), fixture.GetService <IHashService>(), fixture.GetService <IAuthTokenService <long> >(), config, fixture.dbFactory, fixture.GetService <IViewTypeInfoService>()); //, fixture.GetService<IDbWriter>()); //Always want a fresh database! fixture.ResetDatabase(); }