コード例 #1
0
        public void deleteCanceledOfferBySeller(string ContractAddress)
        { //delete the record from db of the unsigned contracts
            var report = (from d in _AssetInContractsContext.AssetsInContract
                          where d.ContractAddress == ContractAddress
                          select d).Single();

            _AssetInContractsContext.AssetsInContract.Remove(report);
            _AssetInContractsContext.SaveChanges();
        }
        private bool InsertAssetInContractToDB(ContractOffer offer, string contractAddress)
        { //update the AssetInContracts table after the contract deployment (=creation)
            AssetInContract newOffer = new AssetInContract();

            newOffer.AssetID         = offer.AssetID;
            newOffer.ContractAddress = "" + contractAddress;
            newOffer.SellerPublicKey = offer.SellerPublicKey;
            newOffer.BuyerPublicKey  = offer.BuyerPublicKey;
            newOffer.Status          = "Ongoing";
            newOffer.DeniedBy        = "None";
            newOffer.Reason          = "None";
            newOffer.DealPrice       = offer.PriceETH;
            _AssetInContractsContext.AssetsInContract.Add(newOffer);
            _AssetInContractsContext.SaveChanges();
            return(true);
        }
コード例 #3
0
        private async Task UpdateContractToApprovedInDB(string ContractAddress)
        { //update registry - contract in "InGoing state" to "Approve" state
            DappAccount          account          = RegulatorController._regulator;
            SmartContractService deployedContract = new SmartContractService(account, ContractAddress);
            Asset dealAsset = await deployedContract.getAssetDestails();

            int             dealAssetID = dealAsset.AssetID;
            AssetInContract report;

            try
            {
                report = (from d in _AssetInContractsContext.AssetsInContract
                          where d.AssetID == dealAssetID && d.Status.Equals("Approved")
                          select d).Single();
            }
            catch (Exception e)
            {
                report = null;
            }


            if (report != null)
            {
                _AssetInContractsContext.AssetsInContract.Remove(report);
                _AssetInContractsContext.SaveChanges();
            }



            var report2 = (from d in _AssetInContractsContext.AssetsInContract
                           where d.ContractAddress == ContractAddress
                           select d).Single();

            report2.Status = "Approved";
            _AssetInContractsContext.AssetsInContract.Update(report2);
            _AssetInContractsContext.SaveChanges();
        }