Beispiel #1
0
        public static long GetVoteCount()
        {
            DBAction injj = new DBAction();
            long     res  = injj.GetAllVoteCount();

            return(res);
        }
Beispiel #2
0
        public IActionResult Get(uint id)
        {
            string cc = Request.Query["userid"];

            DBAction injj = new DBAction();
            long     count;

            if (cc == null)
            {
                count = injj.GetAllVoteCount();
            }
            else
            {
                try
                {
                    count = injj.GetUserVoteCount(uint.Parse(cc));
                }
                catch
                {
                    return(BadRequest());
                }
            }
            if (id <= 0 || (id - 1) * 10 >= count)
            {
                return(BadRequest());
            }
            SplitPageRes res = new SplitPageRes();


            res.PageNum  = id;
            res.SplitNum = 10;
            if (cc == null)
            {
                if (!injj.GetVoteFromNThToMTh(ref res, (id - 1) * 10, id * 10, 10))
                {
                    res.State = 0;
                }
            }
            else
            {
                try
                {
                    if (!injj.GetVoteFromNThToMTh(ref res, (id - 1) * 10, id * 10, 10, uint.Parse(cc)))
                    {
                        res.State = 0;
                    }
                }
                catch
                {
                    return(BadRequest());
                }
            }

            res.State = 1;
            var json = JObject.FromObject(res);

            return(new ObjectResult(json));
        }
Beispiel #3
0
        public IActionResult Get()
        {
            string   cc = Request.Query["userid"];
            long     count;
            DBAction db = new DBAction();

            if (cc == null)
            {
                count = db.GetAllVoteCount();
            }
            else
            {
                try
                {
                    count = db.GetUserVoteCount(uint.Parse(cc));
                }
                catch
                {
                    return(BadRequest());
                }
            }

            long pageNum = 0;

            if (count >= 0)
            {
                pageNum = count / 10;
                if (count % 10 != 0)
                {
                    pageNum += 1;
                }
            }
            var data = new
            {
                PageNum = pageNum
            };

            var json = JObject.FromObject(data);

            return(new ObjectResult(json));
        }