Beispiel #1
0
        //Constructor
        public ScBookingService(ApplicationDbContext dbContext, IHttpContextAccessor httpAccessor,
                                IConfiguration configuration, SessionService sessionService,
                                IViewRenderService viewRenderService, ScCacheService scCacheService)
        {
            // default log level is error (less verbose)
            var logLevel = LogEventLevel.Error;

            //check if this is running on a developer workstation (outside OpenShift)
            string tagName = configuration["TAG_NAME"] ?? "";

            if (tagName.ToLower().Equals("localdev"))
            {
                IsLocalDevEnvironment = true;
                logLevel = LogEventLevel.Debug;
            }

            // check if this is the OpenShift development environment
            if (tagName.ToLower().Equals("dev"))
            {
                logLevel = LogEventLevel.Information;
            }

            //setup error logger settings
            Logger logger = new LoggerConfiguration()
                            .WriteTo.Console(logLevel)
                            .CreateLogger();

            _client            = OnlineBookingClientFactory.GetClient(configuration);
            _dbContext         = dbContext;
            _httpContext       = httpAccessor.HttpContext;
            _session           = sessionService;
            _viewRenderService = viewRenderService;
            _cache             = scCacheService;
            _mailService       = new MailService("SC", configuration, logger);
        }
        /// <summary>
        ///     Gets a cached list of Supreme Court locations
        /// </summary>
        public async Task <Location[]> GetLocationsAsync()
        {
            if (await ExistsAsync(ScLocationInfoKey))
            {
                return(await GetObjectAsync <Location[]>(ScLocationInfoKey));
            }

            IOnlineBooking client = OnlineBookingClientFactory.GetClient(_configuration);

            Location[] locations = await client.getLocationsAsync();

            await SaveObjectAsync(ScLocationInfoKey, locations, CacheSlidingExpirySeconds);

            return(locations);
        }
Beispiel #3
0
 public ApiController(IConfiguration configuration)
 {
     _client = OnlineBookingClientFactory.GetClient(configuration);
 }