Esempio n. 1
0
        private BlockchainProposalModel CreateBlockchainProposalModel(IEnumerable <ProposalPaymentsModel> localProposals, BlockchainProposal blockchainProposal)
        {
            if (localProposals == null || blockchainProposal == null)
            {
                return(null);
            }

            var model = new BlockchainProposalModel();
            var blockLocalProposalMatch = localProposals.OrderByDescending(x => x.DateCreated).FirstOrDefault(x => x.Hash == blockchainProposal.Hash);

            if (blockLocalProposalMatch != null)
            {
                model.Amount = blockLocalProposalMatch.Amount;
            }

            model.Time          = !string.IsNullOrEmpty(blockchainProposal.FeeHash) ? this.BlockchainRepository.GetTime(blockchainProposal.FeeHash) : null;
            model.Name          = blockchainProposal.Name;
            model.Url           = blockchainProposal.Url;
            model.Hash          = blockchainProposal.Hash;
            model.FeeHash       = blockchainProposal.FeeHash;
            model.Yeas          = blockchainProposal.Yeas;
            model.Nays          = blockchainProposal.Nays;
            model.Abstains      = blockchainProposal.Abstains;
            model.Ratio         = Math.Round(blockchainProposal.Ratio, 2);
            model.IsEstablished = blockchainProposal.IsEstablished ? "Yes" : "No";
            model.IsValid       = blockchainProposal.IsValid ? "Yes" : "No";
            model.IsValidReason = blockchainProposal.IsValidReason;
            model.FValid        = blockchainProposal.FValid ? "Yes" : "No";
            return(model);
        }
Esempio n. 2
0
        public static BlockchainProposalModel ToModel(this BlockchainProposal entity)
        {
            if (entity == null)
            {
                throw new System.ArgumentNullException(nameof(entity));
            }

            var model = new BlockchainProposalModel()
            {
                Name          = entity.Name,
                Url           = entity.Url,
                Hash          = entity.Hash,
                FeeHash       = entity.FeeHash,
                Yeas          = entity.Yeas,
                Nays          = entity.Nays,
                Abstains      = entity.Abstains,
                IsEstablished = entity.IsEstablished ? "Yes" : "No",
                IsValid       = entity.IsValid ? "Yes" : "No",
                IsValidReason = entity.IsValidReason,
                FValid        = entity.FValid ? "Yes" : "No",
                Ratio         = entity.Ratio,
                TotalPayment  = entity.TotalPayment
            };

            return(model);
        }
Esempio n. 3
0
        // Builds a complete blockchain proposal
        // with local, manually-entered payment amount and time (for ui)
        private async Task <BlockchainProposalModel> ConstructBlockchainProposalModel(IQueryable <ProposalPayments> localProposals, BlockchainProposal blockchainProposal)
        {
            if (localProposals == null || blockchainProposal == null)
            {
                return(null);
            }

            var model = new BlockchainProposalModel();

            var blockLocalProposalMatch = await localProposals.OrderByDescending(x => x.CreatedAt).FirstOrDefaultAsync(x => x.Hash == blockchainProposal.Hash);

            var masternodeCount = await this.MasternodeCountRepository.GetLatestLocalMasternodeCount();

            if (masternodeCount == null)
            {
                return(null);
            }

            if (blockLocalProposalMatch != null)
            {
                model.Amount = blockchainProposal.TotalPayment == 0.0m ? blockLocalProposalMatch.Amount : Convert.ToInt32(blockchainProposal.TotalPayment) + blockLocalProposalMatch.Amount;
            }

            model.Time          = blockchainProposal.Time.ToString();
            model.Name          = blockchainProposal.Name;
            model.Url           = blockchainProposal.Url;
            model.Hash          = blockchainProposal.Hash;
            model.FeeHash       = blockchainProposal.FeeHash;
            model.Yeas          = blockchainProposal.Yeas;
            model.Nays          = blockchainProposal.Nays;
            model.Abstains      = blockchainProposal.Abstains;
            model.Ratio         = blockchainProposal.Ratio;
            model.IsEstablished = blockchainProposal.IsEstablished ? "Yes" : "No";
            model.IsValid       = blockchainProposal.IsValid ? "Yes" : "No";
            model.IsFunded      = blockchainProposal.IsFunded ? "Yes" : "No";
            model.IsValidReason = blockchainProposal.IsValidReason;
            model.FValid        = blockchainProposal.FValid ? "Yes" : "No";
            model.TotalPayment  = blockchainProposal.TotalPayment;
            return(model);
        }