Ejemplo n.º 1
0
        public object AddTallies(AddTallyData data)
        {
            string user_name = UserCenter.Act(data.session_key);

            if (user_name == null)
            {
                return new { code = ResultCode.InvalidSession }
            }
            ;

            string client_ip = Util.ClientIp();

            if (RecordStore.CheckUser(data.vote_id, data.sbjt_mat, user_name))
            {
                return new { err_msg = "您(" + user_name + ")已經投過票了。" }
            }
            ;
#if !DEBUG
            if (RecordStore.CheckIp(data.vote_id, data.sbjt_mat, client_ip))
            {
                return new { err_msg = "您的IP已經投過票了。" }
            }
            ;
            // return new { err_msg = "您的IP位址(" + client_ip + ")已經投過票了。" };
#endif
            TallyStore.AddTallies(data.vote_id, user_name, data.sbjt_mat, data.tallies);
            RecordStore.AddRecord(data.vote_id, data.sbjt_mat, user_name, client_ip);

            return(new
            {
                code = ResultCode.Success,
            });
        }
Ejemplo n.º 2
0
        public ActionResult GetTallies(string session_key, string vote_id)
        {
            string user_name = UserCenter.Act(session_key);

            if (user_name == null)
            {
                return(Json(new { code = ResultCode.InvalidSession }, JsonRequestBehavior.AllowGet));
            }

            IEnumerable <TallyInfo> tallies = TallyStore.GetTallies(vote_id, user_name);

            return(Json(new
            {
                code = ResultCode.Success,
                tallies = tallies,
            }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 3
0
        public object ResetTallies(AddTallyData data)
        {
            string user_name = UserCenter.Act(data.session_key);

            if (user_name == null)
            {
                return new { code = ResultCode.InvalidSession }
            }
            ;

            RecordStore.ResetRecord(data.vote_id, data.sbjt_mat, user_name);
            TallyStore.ResetTallies(data.vote_id, user_name, data.sbjt_mat);

            return(new
            {
                code = ResultCode.Success,
            });
        }