public AdminIpRegulation UpdateIpRegulation(EditBackendIpRegulationData data)
        {
            var regulation = Repository.AdminIpRegulations.SingleOrDefault(ip => ip.Id == data.Id);

            if (regulation == null)
            {
                throw new RegoException("User does not exist");
            }

            using (var scope = CustomTransactionScope.GetTransactionScope())
            {
                regulation.IpAddress   = data.IpAddress;
                regulation.Description = data.Description;

                regulation.UpdatedBy   = Repository.Admins.SingleOrDefault(u => u.Id == ActorInfoProvider.Actor.Id);
                regulation.UpdatedDate = DateTime.Now;

                Repository.SaveChanges();

                _eventBus.Publish(new AdminIpRegulationUpdated(regulation));
                scope.Complete();
            }

            return(regulation);
        }
Ejemplo n.º 2
0
        public void Can_edit_backend_ip_regulation()
        {
            var form = _backendIpRegulationsPage.OpenNewBackendIpRegulationForm();
            var data = new BackendIpRegulationData
            {
                IpAddress        = TestDataGenerator.GetRandomIpAddress(),
                AdvancedSettings = false,
                Description      = TestDataGenerator.GetRandomStringWithSpecialSymbols(10)
            };
            var submittedBackendIpRegulationForm = form.Submit(data);

            Assert.AreEqual("IP Regulation has been successfully created", submittedBackendIpRegulationForm.ConfirmationMessage);

            submittedBackendIpRegulationForm.Close();
            var editForm = _backendIpRegulationsPage.OpenEditBackendIpRegulationForm(data.IpAddress);
            var editData = new EditBackendIpRegulationData
            {
                IpAddress   = TestDataGenerator.GetRandomIpAddress(),
                Description = TestDataGenerator.GetRandomStringWithSpecialSymbols(10)
            };

            editForm.ClearFieldsOnForm();
            var submittedBackendIpRegulationEditForm = editForm.Submit(editData);

            Assert.AreEqual("IP Regulation has been successfully updated", submittedBackendIpRegulationEditForm.ConfirmationMessage);
        }