예제 #1
0
 public EmailController(
     TolkDbContext dbContext,
     INotificationService notificationService)
 {
     _dbContext           = dbContext;
     _notificationService = notificationService;
 }
예제 #2
0
 public FilesController(TolkDbContext dbContext, ISwedishClock clock, IOptions <TolkOptions> options, IAuthorizationService authorizationService)
 {
     _dbContext            = dbContext;
     _clock                = clock;
     _options              = options.Value;
     _authorizationService = authorizationService;
 }
예제 #3
0
        public async Task CallWebHooks()
        {
            List <int> callIds = null;

            using (TolkDbContext context = _options.GetContext())
            {
                callIds = await context.OutboundWebHookCalls
                          .Where(e => e.DeliveredAt == null && e.FailedTries < NumberOfTries && !e.IsHandling)
                          .Select(e => e.OutboundWebHookCallId)
                          .ToListAsync();

                if (callIds.Any())
                {
                    var calls = context.OutboundWebHookCalls
                                .Where(e => callIds.Contains(e.OutboundWebHookCallId) && e.IsHandling == false)
                                .Select(c => c);
                    await calls.ForEachAsync(c => c.IsHandling = true);

                    await context.SaveChangesAsync();
                }
            }

            _logger.LogInformation("Found {count} outbound web hook calls to send: {callIds}",
                                   callIds.Count, string.Join(", ", callIds));

            if (callIds.Any())
            {
                var tasks = new List <Task>();
                foreach (var callId in callIds)
                {
                    tasks.Add(Task.Factory.StartNew(() => CallWebhook(callId), CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Current));
                }
                await Task.Factory.ContinueWhenAny(tasks.ToArray(), r => { });
            }
        }
예제 #4
0
 public ComplaintServiceTests()
 {
     _tolkDbContext       = CreateTolkDbContext();
     _logger              = Mock.Of <ILogger <ComplaintService> >();
     _notificationService = new StubNotificationService();
     _clock = new StubSwedishClock("2018-12-12 00:00:00");
 }
 public SystemMessageController(
     TolkDbContext dbContext,
     ISwedishClock clock)
 {
     _dbContext = dbContext;
     _clock     = clock;
 }
예제 #6
0
 public RequestGroupController(
     TolkDbContext dbContext,
     IAuthorizationService authorizationService,
     RequestService requestService,
     ISwedishClock clock,
     ILogger <OrderController> logger,
     IOptions <TolkOptions> options,
     InterpreterService interpreterService,
     PriceCalculationService priceCalculationService,
     OrderService orderService,
     ListToModelService listToModelService,
     CacheService cacheService)
 {
     _dbContext            = dbContext;
     _authorizationService = authorizationService;
     _requestService       = requestService;
     _clock                   = clock;
     _logger                  = logger;
     _options                 = options.Value;
     _interpreterService      = interpreterService;
     _priceCalculationService = priceCalculationService;
     _cacheService            = cacheService;
     _orderService            = orderService;
     _listToModelService      = listToModelService;
 }
        public StatisticsServiceTests()
        {
            _tolkDbContext = CreateTolkDbContext();
            _clock         = new StubSwedishClock(DateTimeOffset.Now.ToString());

            var mockLanguages     = MockEntities.MockLanguages;
            var mockRankings      = MockEntities.MockRankings;
            var mockCustomers     = MockEntities.MockCustomers;
            var mockCustomerUsers = MockEntities.MockCustomerUsers(mockCustomers);
            var mockOrders        = MockEntities.MockOrders(mockLanguages, mockRankings, mockCustomerUsers);
            var mockRequisitions  = MockEntities.MockRequisitions(mockOrders);
            var mockComplaints    = MockEntities.MockComplaints(mockOrders);
            var regions           = Region.Regions;

            //Initialize data if not already initialized
            if (!_tolkDbContext.CustomerOrganisations.Any())
            {
                _tolkDbContext.AddRange(mockCustomers);
                _tolkDbContext.AddRange(mockCustomerUsers);
                _tolkDbContext.AddRange(mockLanguages);
                _tolkDbContext.AddRange(mockRankings);
                _tolkDbContext.AddRange(mockOrders);
                _tolkDbContext.AddRange(mockRequisitions);
                _tolkDbContext.AddRange(mockComplaints);
                _tolkDbContext.AddRange(regions);
            }
            _tolkDbContext.SaveChanges();
            _statService = new StatisticsService(_tolkDbContext, _clock);
        }
예제 #8
0
 public LanguageController(
     TolkDbContext dbContext,
     VerificationService verificationService)
 {
     _dbContext           = dbContext;
     _verificationService = verificationService;
 }
예제 #9
0
 public FaqController(
     TolkDbContext dbContext,
     ISwedishClock clock)
 {
     _dbContext = dbContext;
     _clock     = clock;
 }
예제 #10
0
 public WebhookController(TolkDbContext dbContext,
                          INotificationService notificationService,
                          IAuthorizationService authorizationService)
 {
     _dbContext            = dbContext;
     _notificationService  = notificationService;
     _authorizationService = authorizationService;
 }
예제 #11
0
 public StatisticsService(
     TolkDbContext dbContext,
     ISwedishClock clock
     )
 {
     _dbContext = dbContext;
     _clock     = clock;
 }
 public AssignmentController(TolkDbContext dbContext,
                             IAuthorizationService authorizationService,
                             ISwedishClock clock)
 {
     _dbContext            = dbContext;
     _authorizationService = authorizationService;
     _clock = clock;
 }
예제 #13
0
 public ContractController(
     TolkDbContext dbContext,
     ISwedishClock clock,
     CacheService cacheService)
 {
     _dbContext    = dbContext;
     _clock        = clock;
     _cacheService = cacheService;
 }
예제 #14
0
 public ApiUserService(TolkDbContext dbContext,
                       ILogger <ApiUserService> logger,
                       InterpreterService interpreterService
                       )
 {
     _logger             = logger;
     _dbContext          = dbContext;
     _interpreterService = interpreterService;
 }
 public TolkClaimsPrincipalFactory(
     UserManager <AspNetUser> userManager,
     RoleManager <IdentityRole <int> > roleManager,
     IOptions <IdentityOptions> optionsAccessor,
     TolkDbContext dbContext)
     : base(userManager, roleManager, optionsAccessor)
 {
     _dbContext = dbContext;
 }
예제 #16
0
 public SelectListService(
     IDistributedCache cache,
     TolkDbContext dbContext,
     IHttpContextAccessor httpContextAccessor)
 {
     _cache               = cache;
     _dbContext           = dbContext;
     _httpContextAccessor = httpContextAccessor;
 }
 public PriceCalculationService(TolkDbContext dbContext,
                                DateCalculationService dateCalculationService,
                                CacheService cacheService
                                )
 {
     _dbContext = dbContext;
     _dateCalculationService = dateCalculationService;
     _cacheService           = cacheService;
 }
예제 #18
0
 public ErrorNotificationService(
     ILogger <ErrorNotificationService> logger,
     INotificationService notificationService,
     TolkDbContext tolkDbContext
     )
 {
     _logger = logger;
     _notificationService = notificationService;
     _tolkDbContext       = tolkDbContext;
 }
        private CacheService CreateCacheService(TolkDbContext dbContext)
        {
            IDistributedCache      cache         = Mock.Of <IDistributedCache>();
            TolkBaseOptionsService optionService = new TolkBaseOptionsService(Options.Create(new TolkOptions()
            {
                RoundPriceDecimals = true
            }));

            return(new CacheService(cache, dbContext, optionService));
        }
 public InterpreterController(
     TolkDbContext dbContext,
     IAuthorizationService authorizationService,
     InterpreterService interpreterService,
     ISwedishClock clock)
 {
     _dbContext            = dbContext;
     _authorizationService = authorizationService;
     _interpreterService   = interpreterService;
     _clock = clock;
 }
예제 #21
0
 public ComplaintService(
     TolkDbContext dbContext,
     ISwedishClock clock,
     INotificationService notificationService,
     ILogger <ComplaintService> logger
     )
 {
     _dbContext           = dbContext;
     _clock               = clock;
     _notificationService = notificationService;
     _logger              = logger;
 }
예제 #22
0
 public UnitController(
     TolkDbContext dbContext,
     ISwedishClock clock,
     IAuthorizationService authorizationService,
     UserService userService
     )
 {
     _dbContext            = dbContext;
     _clock                = clock;
     _authorizationService = authorizationService;
     _userService          = userService;
 }
        private OrderAgreementService CreateOrderAgreementService(TolkDbContext dbContext, StubSwedishClock clock = null)
        {
            IDistributedCache      cache         = Mock.Of <IDistributedCache>();
            TolkBaseOptionsService optionService = new TolkBaseOptionsService(Options.Create(new TolkOptions()
            {
                RoundPriceDecimals = true
            }));

            _cache = new CacheService(cache, dbContext, optionService);
            var emailService = new EmailService(Mock.Of <ILogger <EmailService> >(), Options.Create(new TolkOptions()), _clock);

            return(new OrderAgreementService(dbContext, _logger, clock ?? _clock, _cache, new DateCalculationService(_cache), optionService, emailService));
        }
예제 #24
0
 public ComplaintController(
     TolkDbContext tolkDbContext,
     ComplaintService complaintService,
     ApiUserService apiUserService,
     ApiOrderService apiOrderService,
     ILogger <ComplaintController> logger
     )
 {
     _dbContext        = tolkDbContext;
     _apiUserService   = apiUserService;
     _complaintService = complaintService;
     _apiOrderService  = apiOrderService;
     _logger           = logger;
 }
예제 #25
0
 public RequisitionService(
     TolkDbContext dbContext,
     ISwedishClock clock,
     INotificationService notificationService,
     ILogger <RequisitionService> logger,
     PriceCalculationService priceCalculationService
     )
 {
     _dbContext               = dbContext;
     _clock                   = clock;
     _notificationService     = notificationService;
     _logger                  = logger;
     _priceCalculationService = priceCalculationService;
 }
 public RequisitionController(
     TolkDbContext tolkDbContext,
     ILogger <RequisitionController> logger,
     RequisitionService requisitionService,
     ApiUserService apiUserService,
     ApiOrderService apiOrderService
     )
 {
     _dbContext          = tolkDbContext;
     _logger             = logger;
     _apiUserService     = apiUserService;
     _requisitionService = requisitionService;
     _apiOrderService    = apiOrderService;
 }
예제 #27
0
 public UserService(
     TolkDbContext dbContext,
     UserManager <AspNetUser> userManager,
     IOptions <TolkOptions> options,
     ISwedishClock clock,
     INotificationService notificationService,
     ILogger <UserService> logger)
 {
     _dbContext           = dbContext;
     _userManager         = userManager;
     _options             = options?.Value;
     _clock               = clock;
     _notificationService = notificationService;
     _logger              = logger;
 }
 public RequestGroupController(
     TolkDbContext tolkDbContext,
     RequestService requestService,
     ApiUserService apiUserService,
     ISwedishClock timeService,
     ApiOrderService apiOrderService,
     ILogger <RequestController> logger)
 {
     _dbContext       = tolkDbContext;
     _apiUserService  = apiUserService;
     _timeService     = timeService;
     _requestService  = requestService;
     _apiOrderService = apiOrderService;
     _logger          = logger;
 }
예제 #29
0
 public CustomerController(
     TolkDbContext dbContext,
     IAuthorizationService authorizationService,
     RoleManager <IdentityRole <int> > roleManager,
     INotificationService notificationService,
     CacheService cacheService,
     ISwedishClock clock)
 {
     _dbContext            = dbContext;
     _authorizationService = authorizationService;
     _roleManager          = roleManager;
     _notificationService  = notificationService;
     _cacheService         = cacheService;
     _clock = clock;
 }
예제 #30
0
 public OrderController(
     TolkDbContext tolkDbContext,
     OrderService orderService,
     ApiOrderService apiOrderService,
     ApiUserService apiUserService,
     ITolkBaseOptions tolkBaseOptions,
     ILogger <OrderController> logger)
 {
     _dbContext       = tolkDbContext;
     _orderService    = orderService;
     _apiOrderService = apiOrderService;
     _tolkBaseOptions = tolkBaseOptions;
     _logger          = logger;
     _apiUserService  = apiUserService;
 }