Ejemplo n.º 1
0
        public static bool OnListProposalPaginated(JToken id, string method, JArray parameters, out JToken result)
        {
            result = new JObject();

            if (parameters == null || parameters.Count != 2)
            {
                result = RpcMessage.CreateErrorResult(id, RpcMessage.INVALID_PARAMS, "Invalid parameters");
                return(false);
            }

            try
            {
                int offset = parameters[0].ToObject <int>();
                int limit  = parameters[1].ToObject <int>();

                ProposalList proposals = RpcApiService.GetListProposalPaginated(offset, limit);

                result = JToken.FromObject(proposals.ToByteArray());
            }
            catch (ArgumentException e)
            {
                result = RpcMessage.CreateErrorResult(id, RpcMessage.INVALID_PARAMS, e.Message);
                return(false);
            }
            catch (System.Exception e)
            {
                result = RpcMessage.CreateErrorResult(id, RpcMessage.UNKNOWN_ERROR, e.Message);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 2
0
        public static ProposalList GetListProposalPaginated(int offset, int limit)
        {
            if (offset < 0 || limit < 0)
            {
                throw new ArgumentException("offset and limit value must be >= 0");
            }

            long latest_num = Manager.Instance.DBManager.DynamicProperties.GetLatestProposalNum();

            if (latest_num <= offset)
            {
                throw new ArgumentException("latest num is " + latest_num + ". offset num  must be smaller than latest.");
            }

            limit = limit > Parameter.DatabaseParameters.PROPOSAL_COUNT_LIMIT_MAX ? Parameter.DatabaseParameters.PROPOSAL_COUNT_LIMIT_MAX : limit;
            long end = offset + limit;

            end = end > latest_num ? latest_num : end;

            ProposalList result = new ProposalList();

            for (int i = offset; i < end; i++)
            {
                ProposalCapsule exchange = Manager.Instance.DBManager.Proposal.Get(ProposalCapsule.CalculateDatabaseKey(i));
                if (exchange != null)
                {
                    result.Proposals.Add(exchange.Instance);
                }
            }

            return(result);
        }
Ejemplo n.º 3
0
        public static ProposalList GetListProposal()
        {
            ProposalList result = new ProposalList();

            foreach (var proposal in Manager.Instance.DBManager.Proposal.AllProposals)
            {
                result.Proposals.Add(proposal.Instance);
            }

            return(result);
        }
        public ActionResult GetProposals(string Uname)
        {
            if (Uname != (string)Session["UserName"])
            {
                return(Content("<script language = 'javascript' type = 'text/javascript'>alert('Sorry, Session Expired!!'); window.location.href = 'login'</script>"));
            }
            Institute       i = (Institute)Session["Institute"];
            string          Curr_Institute = (string)i.Name;
            List <Proposal> All_Proposals  = new ProposalRepository().GetProposals(Curr_Institute);
            ProposalList    p = new ProposalList();

            p.PList = All_Proposals;
            return(View(p));
        }