Example #1
0
        public Hashtable Post([FromBody] int id_exam, [FromBody] int rule, [FromBody] DateTime dateTime, [FromBody] int score, [FromBody] string kind, [FromBody] string detail)
        {
            Hashtable  ht    = new Hashtable();
            RewardInfo ai    = new RewardInfo();
            int        admin = UserInfo.GetUserIdFromCookie(HttpContext.Current);

            try
            {
                ht.Add("state", ai.ChangeContext(id_exam, rule, dateTime, admin, score, kind, detail));
            }
            catch (Exception e)
            {
                ht.Add("state", false);
                ht.Add("reason", e.Message);
            }
            return(ht);
        }
        // PUT api/values/5
        public Hashtable Put(int id, int worker_id, int rule_id, DateTime date, int score)
        {
            Hashtable  ht    = new Hashtable();
            Hashtable  data  = new Hashtable();
            RewardInfo ai    = new RewardInfo();
            int        admin = UserInfo.GetUserIdFromCookie(HttpContext.Current);

            try
            {
                ht.Add("code", 20000);
                ai.ChangeContext(id, rule_id, date, admin, score, null, null);
            }
            catch (Exception e)
            {
                if (ht.ContainsKey("code"))
                {
                    ht.Remove("code");
                }
                ht.Add("code", 40000);
                data.Add("message", e.Message);
            }
            ht.Add("data", data);
            return(ht);
        }