Пример #1
0
        public void Can_activate_payment_level()
        {
            var createPaymentLevelData = CreatePaymentLevelData();

            var id = _paymentLevelCommands.Save(createPaymentLevelData).PaymentLevelId;

            var paymentLevel = _paymentRepository.PaymentLevels.Single(x => x.Id == id);

            paymentLevel.Status = PaymentLevelStatus.Inactive;
            var activatePaymentLevelCommand = new ActivatePaymentLevelCommand {
                Id = id
            };
            var canActivate = _paymentLevelCommands.ValidatePaymentLevelCanBeActivated(activatePaymentLevelCommand);

            Assert.True(canActivate.IsValid);

            _paymentLevelCommands.Activate(activatePaymentLevelCommand);
            var newStatus = _paymentRepository.PaymentLevels.Single(x => x.Id == id).Status;

            Assert.That(newStatus, Is.EqualTo(PaymentLevelStatus.Active));
        }
        public ActionResult Activate(ActivatePaymentLevelCommand data)
        {
            var validationResult = _paymentLevelCommands.ValidatePaymentLevelCanBeActivated(data);

            if (!validationResult.IsValid)
            {
                return(ValidationErrorResponseActionResult(validationResult.Errors));
            }

            _paymentLevelCommands.Activate(data);

            return(this.Success());
        }