public IdentificationDocumentSettings UpdateSetting(IdentificationDocumentSettingsData data)
        {
            var setting = GetSettingById(data.Id);

            if (setting == null)
            {
                throw new RegoException("Setting not found");
            }

            ValidateData(data, IdentificationAction.Update);

            setting.BrandId    = data.BrandId;
            setting.LicenseeId = data.LicenseeId;
            setting.PaymentGatewayBankAccountId = data.PaymentGatewayBankAccountId;
            setting.PaymentGatewayMethod        = data.PaymentGatewayMethod;
            setting.TransactionType             = data.TransactionType;
            setting.IdBack          = data.IdBack;
            setting.IdFront         = data.IdFront;
            setting.CreditCardBack  = data.CreditCardBack;
            setting.CreditCardFront = data.CreditCardFront;
            setting.DCF             = data.DCF;
            setting.POA             = data.POA;
            setting.Remark          = data.Remark;

            setting.UpdatedBy = _actorInfoProvider.Actor.UserName;
            setting.UpdatedOn = DateTimeOffset.UtcNow;

            _repository.SaveChanges();

            _eventBus.Publish(new IdentificationDocumentSettingsUpdated(setting));

            return(setting);
        }
示例#2
0
        public void WhenNewIdentificationSettingsIsCreated()
        {
            ScenarioContext.Current.Should().ContainKey("brandId");
            var brandId = ScenarioContext.Current.Get <Guid>("brandId");

            ScenarioContext.Current.Should().ContainKey("licenseeId");
            var licenseeId = ScenarioContext.Current.Get <Guid>("licenseeId");

            ScenarioContext.Current.Should().ContainKey("bankAccountId");
            var bankAccountId = ScenarioContext.Current.Get <Guid>("bankAccountId");

            var data = new IdentificationDocumentSettingsData
            {
                LicenseeId                  = licenseeId,
                BrandId                     = brandId,
                TransactionType             = TransactionType.Deposit,
                PaymentGatewayBankAccountId = bankAccountId,
                PaymentGatewayMethod        = PaymentMethod.OfflineBank,
                IdFront                     = true,
                IdBack          = true,
                CreditCardFront = true,
                CreditCardBack  = true,
                POA             = true,
                DCF             = true,
                Remark          = TestDataGenerator.GetRandomString()
            };

            var identificationDocumentSettings = Container.Resolve <IdentificationDocumentSettingsService>().CreateSetting(data);

            ScenarioContext.Current.Add("identificationDocumentSettingsId", identificationDocumentSettings.Id);
        }
示例#3
0
        public void ThenNewIdentificationSettingsIsSuccessfullyCreated()
        {
            ScenarioContext.Current.Should().ContainKey("brandId");
            var brandId = ScenarioContext.Current.Get <Guid>("brandId");

            ScenarioContext.Current.Should().ContainKey("licenseeId");
            var licenseeId = ScenarioContext.Current.Get <Guid>("licenseeId");

            ScenarioContext.Current.Should().ContainKey("bankAccountId");
            var bankAccountId = ScenarioContext.Current.Get <Guid>("bankAccountId");

            var data = new IdentificationDocumentSettingsData
            {
                LicenseeId                  = licenseeId,
                BrandId                     = brandId,
                TransactionType             = TransactionType.Deposit,
                PaymentGatewayBankAccountId = bankAccountId,
                PaymentGatewayMethod        = PaymentMethod.OfflineBank,
                IdFront                     = true,
                IdBack          = true,
                CreditCardFront = true,
                CreditCardBack  = true,
                POA             = true,
                DCF             = true,
                Remark          = TestDataGenerator.GetRandomString()
            };

            var result = AdminApiProxy.CreateSettingInIdentificationDocumentSettings(data);

            result.Should().NotBeNull();
            result.StatusCode.ShouldBeEquivalentTo(HttpStatusCode.OK);
        }
示例#4
0
        public IHttpActionResult CreateSetting(IdentificationDocumentSettingsData data)
        {
            VerifyPermission(Permissions.Create, Modules.IdentificationDocumentSettings);

            try
            {
                _service.CreateSetting(data);
            }
            catch (Exception ex)
            {
                return(Ok(new { result = "fail", data = ex.Message }));
            }

            return(Ok(new { result = "success" }));
        }
        public IdentificationDocumentSettings CreateSetting(IdentificationDocumentSettingsData data)
        {
            ValidateData(data, IdentificationAction.Create);
            var setting = AutoMapper.Mapper.DynamicMap <IdentificationDocumentSettings>(data);

            setting.Id        = Guid.NewGuid();
            setting.CreatedBy = _actorInfoProvider.Actor.UserName;
            setting.CreatedOn = DateTimeOffset.UtcNow;

            _repository.IdentificationDocumentSettings.Add(setting);

            _repository.SaveChanges();

            _eventBus.Publish(new IdentificationDocumentSettingsCreated(setting));

            return(setting);
        }
        private void ValidateData(IdentificationDocumentSettingsData data, IdentificationAction action)
        {
            var settings = _repository.IdentificationDocumentSettings.AsQueryable();

            if (action == IdentificationAction.Update)
            {
                settings = settings.Where(o => o.Id != data.Id);
            }

            if (settings.Any(
                    record =>
                    record.BrandId == data.BrandId &&
                    record.PaymentGatewayBankAccountId == data.PaymentGatewayBankAccountId &&
                    record.TransactionType == data.TransactionType))
            {
                throw new RegoException(
                          "You have already set up Identification Document Setting with the selected Brand, Payment Method and Transaction Type. Please, update the existing one or change your form data.");
            }
        }
示例#7
0
 public HttpResponseMessage UpdateSettingInIdentificationDocumentSettings(IdentificationDocumentSettingsData request)
 {
     return(WebClient.SecurePostAsJson <IdentificationDocumentSettingsData, HttpResponseMessage>(Token, _url + AdminApiRoutes.UpdateSettingInIdentificationDocumentSettings, request));
 }