示例#1
0
        public async Task TestCreateIntegration()
        {
            int uniqueValue = new Random().Next(1000, 100000);

            var integration = new contracts.Integration
            {
                IsActivated    = false,
                UnitId         = 6,
                Category       = 1,
                ExternalSystem = uniqueValue,
            };

            // Act
            var createdIntegration = await _client.PostAsyncAndDeserialize <contracts.Integration, contracts.Integration>($"{_customerId}/integrations", integration);

            // Assert
            Assert.NotNull(createdIntegration);
            Assert.NotZero(createdIntegration.Id);

            var integrationInDb = _db.Integrations.FirstOrDefault(x => x.ExternalSystem == uniqueValue);

            Assert.NotNull(integrationInDb);
            Assert.NotZero(integrationInDb.Id);
            Assert.AreEqual(createdIntegration.Id, integrationInDb.Id);
        }
示例#2
0
        public async Task <ActionResult <contracts.Integration> > Update([FromBody] contracts.Integration integration)
        {
            var mapIntegration    = _mapper.Map <contracts.Integration, domain.Integration>(integration);
            var integrationResult = await _integrationService.UpdateIntegration(mapIntegration);

            var updatedIntegrationContracts = _mapper.Map <domain.Integration, contracts.Integration>(integrationResult);

            return(Ok(updatedIntegrationContracts));
        }
示例#3
0
 public IntegrationServiceBuilder WithIntegration(Integrations.Api.Contracts.Integration integration)
 {
     _integrations.Add(integration);
     return(this);
 }
示例#4
0
        private async Task <ITimeregValidationResult> Validate(int unitId, int employeeId, integrationsContracts.Integration integration)
        {
            var validationResult = _integrationValidator.Validate(integration);

            if (validationResult.SkipFurtherProcessing)
            {
                return(validationResult);
            }
            else
            {
                var validatorFactory = _validatorFactory.Create(integration.ExternalSystem);
                validationResult = await validatorFactory.ValidateHourBalance(unitId, employeeId);
            }
            return(validationResult);
        }