public ActionResult Add(Provider provider, string UCounty)
 {
     provider.CreateTime = DateTime.Now;
     provider.AddressId  = addressService.GetEntities(a => a.Aid == UCounty).FirstOrDefault().Id;
     providerService.Add(provider);
     providerService.DbSession.SaveChanges <DataModelContainer>();
     return(RedirectToAction("Index", new { pageIndex = Session["pageIndex"] }));
 }
Example #2
0
        static void Main(string[] args)
        {
            Provider p = new Provider
            {
                Username        = "******",
                Password        = "******",
                ConfirmPassword = "******",
                Email           = "fjdkjkf",
                products        = new List <Product>
                {
                }
            };


            Provider p2 = new Provider
            {
                Username        = "******",
                Password        = "******",
                ConfirmPassword = "******",
                Email           = "kdjfglkdfjlgj",
                products        = new List <Product>
                {
                }
            };

            ProviderService s = new ProviderService();

            s.Add(p);
            s.Add(p2);
            s.Commit();
            List <Provider> providers = new List <Provider>();

            providers = s.getByName("marwen");
            foreach (var item in providers)
            {
                System.Console.WriteLine(item.Password);
            }
            System.Console.ReadKey();
        }
        public void Setup()
        {
            DataAssetProvider provider = new DataAssetProvider(_providerAddress, "provider");

            _asset                 = new DataAsset(Keccak.Compute("1"), "name", "desc", 1, DataAssetUnitType.Unit, 1000, 10000, new DataAssetRules(new DataAssetRule(1)), provider, state: DataAssetState.Published);
            _closedAsset           = new DataAsset(Keccak.Compute("2"), "name", "desc", 1, DataAssetUnitType.Unit, 1000, 10000, new DataAssetRules(new DataAssetRule(1)), provider, state: DataAssetState.Closed);
            _assetUnderMaintenance = new DataAsset(Keccak.Compute("3"), "name", "desc", 1, DataAssetUnitType.Unit, 1000, 10000, new DataAssetRules(new DataAssetRule(1)), provider, state: DataAssetState.UnderMaintenance);
            _withKyc               = new DataAsset(Keccak.Compute("4"), "name", "desc", 1, DataAssetUnitType.Unit, 1000, 10000, new DataAssetRules(new DataAssetRule(1)), provider, state: DataAssetState.Published, kycRequired: true);

            _deposit = new Deposit(Keccak.Zero, 1, 2, 3);
            _details = new DepositDetails(_deposit, _asset, Address.Zero, new byte[0], 1, new TransactionInfo[0]);

            INdmBlockchainBridge blockchainBridge = BlockchainBridgeBuilder.BuildABridge();

            _wallet = new DevWallet(new WalletConfig(), LimboLogs.Instance);
            DepositService             depositService     = new DepositService(blockchainBridge, new AbiEncoder(), _wallet, Address.Zero);
            IConsumerSessionRepository sessionRepository  = new ConsumerSessionInMemoryRepository();
            DepositUnitsCalculator     unitsCalculator    = new DepositUnitsCalculator(sessionRepository, Timestamper.Default);
            DepositsInMemoryDb         depositsInMemoryDb = new DepositsInMemoryDb();

            depositsInMemoryDb.Add(_details);

            IProviderRepository     providerRepository     = new ProviderInMemoryRepository(depositsInMemoryDb);
            IConsumerNotifier       notifier               = new ConsumerNotifier(Substitute.For <INdmNotifier>());
            DataAssetService        dataAssetService       = new DataAssetService(providerRepository, notifier, LimboLogs.Instance);
            IDepositUnitsCalculator depositUnitsCalculator = Substitute.For <IDepositUnitsCalculator>();
            INdmPeer peer = Substitute.For <INdmPeer>();

            peer.NodeId.Returns(TestItem.PublicKeyB);
            peer.ProviderAddress.Returns(_providerAddress);

            dataAssetService.AddDiscovered(_asset, peer);
            dataAssetService.AddDiscovered(_closedAsset, peer);
            dataAssetService.AddDiscovered(_assetUnderMaintenance, peer);
            dataAssetService.AddDiscovered(_withKyc, peer);

            _kycVerifier = Substitute.For <IKycVerifier>();
            ProviderService providerService = new ProviderService(providerRepository, notifier, LimboLogs.Instance);

            providerService.Add(peer);

            _depositManager = new DepositManager(depositService, unitsCalculator, dataAssetService, _kycVerifier, providerService, new AbiEncoder(), new CryptoRandom(), _wallet, Substitute.For <IGasPriceService>(), new DepositDetailsInMemoryRepository(depositsInMemoryDb, depositUnitsCalculator), Timestamper.Default, LimboLogs.Instance, 6, false);
        }
Example #4
0
        public void Setup()
        {
            INdmPeer peer = Substitute.For <INdmPeer>();

            peer.ProviderAddress.Returns(_providerAddress);
            _providerId = TestItem.PublicKeyB;
            peer.NodeId.Returns(_providerId);

            DataAssetProvider provider = new DataAssetProvider(_providerAddress, "name");

            DataAsset newPendingAsset = new DataAsset(_newPendingAssetId, "name", "desc", 1, DataAssetUnitType.Unit, 1000, 10000, new DataAssetRules(new DataAssetRule(1), null), provider);
            DataAsset pendingAsset    = new DataAsset(_pendingAssetId, "name", "desc", 1, DataAssetUnitType.Unit, 1000, 10000, new DataAssetRules(new DataAssetRule(1), null), provider);
            DataAsset rejectedAsset   = new DataAsset(_rejectedAssetId, "name", "desc", 1, DataAssetUnitType.Unit, 1000, 10000, new DataAssetRules(new DataAssetRule(1), null), provider);
            DataAsset confirmedAsset  = new DataAsset(_confirmedAssetId, "name", "desc", 1, DataAssetUnitType.Unit, 1000, 10000, new DataAssetRules(new DataAssetRule(1), null), provider);

            DepositsInMemoryDb         db = new DepositsInMemoryDb();
            ProviderInMemoryRepository providerRepository = new ProviderInMemoryRepository(db);

            _cdaRepo     = new ConsumerDepositApprovalInMemoryRepository();
            _ndmNotifier = Substitute.For <INdmNotifier>();
            ConsumerNotifier notifier         = new ConsumerNotifier(_ndmNotifier);
            DataAssetService dataAssetService = new DataAssetService(providerRepository, notifier, LimboLogs.Instance);

            dataAssetService.AddDiscovered(newPendingAsset, peer);
            dataAssetService.AddDiscovered(pendingAsset, peer);
            dataAssetService.AddDiscovered(rejectedAsset, peer);
            dataAssetService.AddDiscovered(confirmedAsset, peer);

            _providerService = new ProviderService(providerRepository, notifier, LimboLogs.Instance);
            _providerService.Add(peer);

            _service = new DepositApprovalService(dataAssetService, _providerService, _cdaRepo, Timestamper.Default, notifier, LimboLogs.Instance);

            _confirmedApproval = new DepositApproval(Keccak.Compute(Rlp.Encode(Rlp.Encode(_confirmedAssetId), Rlp.Encode(_consumerAddress)).Bytes), _confirmedAssetId, "asset", "kyc", _consumerAddress, _providerAddress, 1, DepositApprovalState.Confirmed);
            _pendingApproval   = new DepositApproval(Keccak.Compute(Rlp.Encode(Rlp.Encode(_pendingAssetId), Rlp.Encode(_consumerAddress)).Bytes), _pendingAssetId, "asset", "kyc", _consumerAddress, _providerAddress, 1, DepositApprovalState.Pending);
            _rejectedApproval  = new DepositApproval(Keccak.Compute(Rlp.Encode(Rlp.Encode(_rejectedAssetId), Rlp.Encode(_consumerAddress)).Bytes), _rejectedAssetId, "asset", "kyc", _consumerAddress, _providerAddress, 1, DepositApprovalState.Rejected);

            _cdaRepo.AddAsync(_confirmedApproval);
            _cdaRepo.AddAsync(_pendingApproval);
            _cdaRepo.AddAsync(_rejectedApproval);
        }
Example #5
0
        public ActionResult CreateProvider(Provider providerForm)
        {
            try
            {
                Provider        pr = new Provider();
                ProviderService p  = new ProviderService();

                pr.Email           = providerForm.Email;
                pr.Username        = providerForm.Username;
                pr.Password        = providerForm.Password;
                pr.ConfirmPassword = providerForm.ConfirmPassword;
                p.Add(pr);
                p.Commit();

                return(RedirectToAction("getProviders"));
            }
            catch
            {
                return(View());
            }
        }