public void Can_deactivate_paymentGatewaySettings()
        {
            // Arrange
            var brand = Container.Resolve <BrandTestHelper>().CreateBrand(isActive: true);

            var repositorySettings = new PaymentGatewaySettings
            {
                Id      = new Guid("50797305-5320-4086-BA1C-9D062DDF53D9"),
                BrandId = brand.Id,
                Status  = Status.Active
            };

            _paymentRepository.PaymentGatewaySettings.Add(repositorySettings);

            // Act
            _commands.Deactivate(new DeactivatePaymentGatewaySettingsData
            {
                Id      = repositorySettings.Id,
                Remarks = "remark"
            });

            //Assert
            var settings = _paymentRepository.PaymentGatewaySettings.Single(x => x.Id == repositorySettings.Id);

            settings.Status.Should().Be(Status.Inactive);
            settings.DeactivatedBy.ShouldBeEquivalentTo(_actorInfoProvider.Actor.UserName);
            settings.DateDeactivated.Should().BeCloseTo(DateTime.Now, 5000);
        }
Пример #2
0
        public DeactivatePaymentGatewaySettingsResponse Deactivate(DeactivatePaymentGatewaySettingsRequest request)
        {
            VerifyPermission(Permissions.Deactivate, Modules.PaymentGatewaySettings);

            var model = Mapper.DynamicMap <Core.Payment.Interface.Data.Commands.DeactivatePaymentGatewaySettingsData>(request);

            var validatResult = _paymentGatewaySettingsCommands.ValidateThatPaymentGatewaySettingsCanBeDeactivated(model);

            if (false == validatResult.IsValid)
            {
                return(ValidationErrorResponse <DeactivatePaymentGatewaySettingsResponse>(validatResult));
            }

            var setting = _paymentGatewaySettingsQueries.GetPaymentGatewaySettingsById(request.Id);

            CheckBrand(setting.BrandId);

            _paymentGatewaySettingsCommands.Deactivate(model);
            return(new DeactivatePaymentGatewaySettingsResponse
            {
                Success = true
            });
        }