//public async Task DetectNewProofRequest()
        //{
        //    var context = await _agentContextProvider.GetContextAsync();

        //    foreach (var proofRequest in ProofRequests)
        //    {
        //        if (proofRequest.IsNew)
        //        {
        //            var record = await _recordService.GetAsync<ProofRecord>(context.Wallet, proofRequest.Id);
        //            record.SetTag("IsNew", "false");
        //            await _recordService.UpdateAsync(context.Wallet, record);
        //            await SelectProofRequest(proofRequest);
        //            break;
        //        }
        //    }
        //}

        public async Task RefreshProofs()
        {
            RefreshingProofRequests = true;

            IAgentContext context = await _agentContextProvider.GetContextAsync();

            IList <ProofRecord> proofRecords = await _proofService.ListAsync(context);

            IList <ProofRequestViewModel> proofs = await _proofAssembler.AssembleMany(proofRecords);

            IEnumerable <ProofRequestViewModel> filteredProofVms = FilterProofRequests(SearchTerm, proofs);

            IEnumerable <Grouping <string, ProofRequestViewModel> > groupedVms = GroupProofRequests(filteredProofVms);

            ProofRequestsGrouped = groupedVms;

            ProofRequestsCount = String.Format("Nombre de preuve", proofRecords.Count); //AppResources.ProofRequestCount

            HasProofRequests = ProofRequests.Any();

            ProofRequests.Clear();

            ProofRequests.InsertRange(filteredProofVms);

            RefreshingProofRequests = false;
        }
Example #2
0
        public async Task RefreshProofRequests()
        {
            try
            {
                RefreshingProofRequests = true;
                ProofRequests.Clear();

                var agentContext = await _agentContextProvider.GetContextAsync();

                IEnumerable <ProofRecord> proofRequests = (await _proofService.ListRequestedAsync(agentContext));

                IList <ProofRequestViewModel> proofRequestVms = new List <ProofRequestViewModel>();
                foreach (var proofReq in proofRequests)
                {
                    var connection = await _connectionService.GetAsync(agentContext, proofReq.ConnectionId);

                    var proofRequestViewModel = _scope.Resolve <ProofRequestViewModel>(new NamedParameter("proofRecord", proofReq), new NamedParameter("connection", connection));
                    proofRequestVms.Add(proofRequestViewModel);
                }

                ProofRequests.InsertRange(proofRequestVms);
                HasRequests = ProofRequests.Any();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                RefreshingProofRequests = false;
            }
        }
        public async Task RefreshProofRequests(string tab = null)
        {
            try
            {
                RefreshingProofRequests = true;
                ProofRequests.Clear();

                var agentContext = await _agentContextProvider.GetContextAsync();

                IEnumerable <ProofRecord> proofRequests = null;
                if (tab == null || tab.Equals(nameof(ProofState.Requested)))
                {
                    proofRequests = await _proofService.ListRequestedAsync(agentContext);
                }
                else if (tab.Equals(nameof(ProofState.Accepted)))
                {
                    proofRequests = await _proofService.ListAcceptedAsync(agentContext);
                }
                else if (tab.Equals(nameof(ProofState.Proposed)))
                {
                    proofRequests = await _proofService.ListProposedAsync(agentContext);
                }

                IList <ProofRequestViewModel> proofRequestVms = new List <ProofRequestViewModel>();
                foreach (var proofReq in proofRequests)
                {
                    var connection = (proofReq.ConnectionId == null) ? null : await _connectionService.GetAsync(agentContext, proofReq.ConnectionId);

                    var proofRequestViewModel = _scope.Resolve <ProofRequestViewModel>(new NamedParameter("proofRecord", proofReq), new NamedParameter("connection", connection));
                    proofRequestVms.Add(proofRequestViewModel);
                }

                ProofRequests.InsertRange(proofRequestVms);
                HasRequests = ProofRequests.Any();
            }
            catch (Exception xx)
            {
                await UserDialogs.Instance.AlertAsync(xx.Message);

                Debug.WriteLine(xx.StackTrace);
            }
            finally
            {
                RefreshingProofRequests = false;
            }
        }