Exemplo n.º 1
0
        public bool CheckProof(string hash)
        {
            var proofFilter = new ProofFilter
            {
                Hash     = hash,
                Statuses = new[] { Constants.ProofStatus.Confirmed }
            };
            var proofs = DataService.GetProofs(proofFilter);

            return(proofs.Proofs.Any());
        }
Exemplo n.º 2
0
        public Proof CheckFee(string hash)
        {
            var proofFilter = new ProofFilter
            {
                Hash     = hash,
                Statuses = new[] { Constants.ProofStatus.ProofPending, Constants.ProofStatus.ConfirmPending, Constants.ProofStatus.Confirmed }
            };
            var proofs = DataService.GetProofs(proofFilter);

            return(proofs.Proofs.FirstOrDefault());
        }
Exemplo n.º 3
0
        public bool CheckProofPayment(string hash, string address)
        {
            var proofFilter = new ProofFilter
            {
                Hash     = hash,
                Statuses = new[] { Constants.ProofStatus.ProofPending }
            };
            var proofs = DataService.GetProofs(proofFilter);

            return(proofs.Proofs.Any());
        }
Exemplo n.º 4
0
        public ProofCollection GetPendingProofs(int?skip, int?limit, string search)
        {
            var proofFilter = new ProofFilter
            {
                Statuses   = new [] { Constants.ProofStatus.PaymentPending, Constants.ProofStatus.ProofPending, Constants.ProofStatus.ConfirmPending },
                SortByDate = SortOrder.Descending,
                Skip       = skip,
                Limit      = limit,
                Search     = search
            };

            return(DataService.GetProofs(proofFilter));
        }
Exemplo n.º 5
0
 public ProofCollection GetProofs(ProofFilter proofFilter)
 {
     return(Repository.GetProofs(proofFilter));
 }
Exemplo n.º 6
0
        public ProofCollection GetProofs(ProofFilter proofFilter = null)
        {
            List <MongoProof> data;
            var proofCollection = new ProofCollection();

            var collection = Database.GetCollection <MongoProof>(Proofs);
            var builder    = Builders <MongoProof> .Filter;
            var filterDefs = new List <FilterDefinition <MongoProof> >();

            if (proofFilter != null)
            {
                if (!string.IsNullOrWhiteSpace(proofFilter.Hash))
                {
                    filterDefs.Add(builder.Eq(x => x.Hash, proofFilter.Hash));
                }

                if (!string.IsNullOrWhiteSpace(proofFilter.Address))
                {
                    filterDefs.Add(builder.Eq(x => x.PayAddress.Address, proofFilter.Address));
                }

                if (proofFilter.Statuses != null && proofFilter.Statuses.Any())
                {
                    filterDefs.Add(builder.In(x => x.Status, proofFilter.Statuses));
                }

                if (proofFilter.PayAmount.HasValue)
                {
                    filterDefs.Add(builder.Eq(x => x.PayAmount, proofFilter.PayAmount.Value));
                }
                if (proofFilter.PayConfirmed.HasValue)
                {
                    filterDefs.Add(builder.Eq(x => x.PayConfirmed, proofFilter.PayConfirmed.Value));
                }
                if (proofFilter.PayDate.HasValue)
                {
                    filterDefs.Add(builder.Eq(x => x.PayDate, proofFilter.PayDate));
                }
                if (!string.IsNullOrWhiteSpace(proofFilter.Search))
                {
                    filterDefs.Add(builder.Or(new[]
                    {
                        builder.Regex(x => x.PayAddress.Address, new BsonRegularExpression(proofFilter.Search)),
                        builder.Regex(x => x.Hash, new BsonRegularExpression(proofFilter.Search)),
                    }));
                }

                var filterDef = filterDefs.Any() ? filterDefs.Aggregate((x, y) => x & y) : builder.Empty;
                var recs      = collection.Find <MongoProof>(filterDef);

                proofCollection.Total = recs.Count();

                if (proofFilter.SortByDate == SortOrder.Ascending)
                {
                    recs = recs.SortBy(x => x.DateCreated);
                }
                else
                if (proofFilter.SortByDate == SortOrder.Descending)
                {
                    recs = recs.SortByDescending(x => x.DateCreated);
                }
                if (proofFilter.Skip.HasValue)
                {
                    recs = recs.Skip(proofFilter.Skip);
                    proofCollection.Skip = proofFilter.Skip;
                }
                if (proofFilter.Limit.HasValue)
                {
                    recs = recs.Limit(proofFilter.Limit);
                    proofCollection.Limit = proofFilter.Limit;
                }
                data = recs.ToList();
                proofCollection.Proofs = data;
            }
            else
            {
                data = collection.Find <MongoProof>(builder.Empty).ToList();
                proofCollection.Total  = data.Count();
                proofCollection.Proofs = data;
            }

            return(proofCollection);
        }